mirror of
https://github.com/kubevela/kubevela.git
synced 2026-04-23 19:16:42 +00:00
Fix: storage patch env (#4523)
* Fix: empty health policy do not check object existence Signed-off-by: Somefive <yd219913@alibaba-inc.com> * Fix: fix health check error Signed-off-by: Somefive <yd219913@alibaba-inc.com> * Fix: app use storage and env trait Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -115,6 +115,9 @@ func listMergeProcess(field *ast.Field, key string, baseList, patchList *ast.Lis
|
||||
kmaps[fmt.Sprintf(key, blit.Value)] = patchList.Elts[i]
|
||||
}
|
||||
if !foundPatch {
|
||||
if len(patchList.Elts) == 0 {
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,19 @@ containers: [{noname: "x3"}]`,
|
||||
base: `containers: [{name: "x1"},{name: "x2"},...]`,
|
||||
patch: `
|
||||
// +patchKey=name
|
||||
containers: []`,
|
||||
result: `// +patchKey=name
|
||||
containers: [{
|
||||
name: "x1"
|
||||
}, {
|
||||
name: "x2"
|
||||
}, ...]
|
||||
`,
|
||||
},
|
||||
{
|
||||
base: `containers: [{name: "x1"},{name: "x2"},...]`,
|
||||
patch: `
|
||||
// +patchKey=name
|
||||
containers: [{noname: "x3"},{name: "x1"}]`,
|
||||
result: `// +patchKey=name
|
||||
containers: [{
|
||||
@@ -359,8 +372,10 @@ containers: [{
|
||||
}
|
||||
|
||||
for i, tcase := range testCase {
|
||||
v, _ := StrategyUnify(tcase.base, tcase.patch)
|
||||
assert.Equal(t, v, tcase.result, fmt.Sprintf("testPatch for case(no:%d) %s", i, v))
|
||||
t.Run(fmt.Sprintf("case-%d", i), func(t *testing.T) {
|
||||
v, _ := StrategyUnify(tcase.base, tcase.patch)
|
||||
assert.Equal(t, v, tcase.result, fmt.Sprintf("testPatch for case(no:%d) %s", i, v))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -590,5 +590,18 @@ var _ = Describe("Test multicluster scenario", func() {
|
||||
g.Expect(k8sClient.Get(hubCtx, client.ObjectKeyFromObject(app), app)).Should(Satisfy(kerrors.IsNotFound))
|
||||
}, 10*time.Second).Should(Succeed())
|
||||
})
|
||||
|
||||
It("Test applications with env and storage trait", func() {
|
||||
bs, err := ioutil.ReadFile("./testdata/app/app-with-env-and-storage.yaml")
|
||||
Expect(err).Should(Succeed())
|
||||
appYaml := strings.ReplaceAll(string(bs), "TEST_NAMESPACE", testNamespace)
|
||||
app := &v1beta1.Application{}
|
||||
Expect(yaml.Unmarshal([]byte(appYaml), app)).Should(Succeed())
|
||||
Expect(k8sClient.Create(hubCtx, app)).Should(Succeed())
|
||||
Eventually(func(g Gomega) {
|
||||
g.Expect(k8sClient.Get(hubCtx, client.ObjectKeyFromObject(app), app)).Should(Succeed())
|
||||
g.Expect(app.Status.Phase).Should(Equal(common.ApplicationRunning))
|
||||
}, 20*time.Second).Should(Succeed())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
24
test/e2e-multicluster-test/testdata/app/app-with-env-and-storage.yaml
vendored
Normal file
24
test/e2e-multicluster-test/testdata/app/app-with-env-and-storage.yaml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-with-env-and-storage
|
||||
namespace: TEST_NAMESPACE
|
||||
spec:
|
||||
components:
|
||||
- name: data-worker
|
||||
type: worker
|
||||
properties:
|
||||
image: busybox
|
||||
cmd:
|
||||
- sleep
|
||||
- '1000000'
|
||||
traits:
|
||||
- type: env
|
||||
properties:
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
- type: storage
|
||||
properties:
|
||||
emptyDir:
|
||||
- name: jvm
|
||||
mountPath: /jvm
|
||||
Reference in New Issue
Block a user