mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
Test: fix resource tracker e2e (#2281)
This commit is contained in:
@@ -411,6 +411,13 @@ func (af *Appfile) setWorkloadRefToTrait(wlRef corev1.ObjectReference, trait *un
|
||||
if traitType == definition.AuxiliaryWorkload {
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(traitType, "-") {
|
||||
splitName := traitType[0:strings.LastIndex(traitType, "-")]
|
||||
_, ok := af.RelatedTraitDefinitions[splitName]
|
||||
if ok {
|
||||
traitType = splitName
|
||||
}
|
||||
}
|
||||
traitDef, ok := af.RelatedTraitDefinitions[traitType]
|
||||
if !ok {
|
||||
return errors.Errorf("TraitDefinition %s not found in appfile", traitType)
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -153,6 +154,7 @@ func LoadTemplateFromRevision(capName string, capType types.CapType, apprev *v1b
|
||||
if apprev == nil {
|
||||
return nil, errors.Errorf("fail to find template for %s as app revision is empty", capName)
|
||||
}
|
||||
capName = verifyRevisionName(capName, capType, apprev)
|
||||
switch capType {
|
||||
case types.TypeComponentDefinition:
|
||||
cd, ok := apprev.Spec.ComponentDefinitions[capName]
|
||||
@@ -231,6 +233,34 @@ func LoadTemplateFromRevision(capName string, capType types.CapType, apprev *v1b
|
||||
}
|
||||
}
|
||||
|
||||
func verifyRevisionName(capName string, capType types.CapType, apprev *v1beta1.ApplicationRevision) string {
|
||||
if strings.Contains(capName, "@") {
|
||||
splitName := capName[0:strings.LastIndex(capName, "@")]
|
||||
ok := false
|
||||
|
||||
switch capType {
|
||||
case types.TypeComponentDefinition:
|
||||
_, ok = apprev.Spec.ComponentDefinitions[splitName]
|
||||
case types.TypeTrait:
|
||||
_, ok = apprev.Spec.TraitDefinitions[splitName]
|
||||
case types.TypePolicy:
|
||||
_, ok = apprev.Spec.PolicyDefinitions[splitName]
|
||||
case types.TypeWorkflowStep:
|
||||
_, ok = apprev.Spec.WorkflowStepDefinitions[splitName]
|
||||
case types.TypeScope:
|
||||
_, ok = apprev.Spec.ScopeDefinitions[splitName]
|
||||
default:
|
||||
return capName
|
||||
}
|
||||
|
||||
if ok {
|
||||
return splitName
|
||||
}
|
||||
}
|
||||
|
||||
return capName
|
||||
}
|
||||
|
||||
// DryRunTemplateLoader return a function that do the same work as
|
||||
// LoadTemplate, but load template from provided ones before loading from
|
||||
// cluster through LoadTemplate
|
||||
|
||||
@@ -125,7 +125,7 @@ var _ = Describe("Test application of the specified definition version", func()
|
||||
Expect(k8sClient.Delete(ctx, &ns, client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed())
|
||||
})
|
||||
|
||||
PIt("Test deploy application which containing cue rendering module", func() {
|
||||
It("Test deploy application which containing cue rendering module", func() {
|
||||
var (
|
||||
appName = "test-website-app"
|
||||
comp1Name = "front"
|
||||
@@ -322,7 +322,7 @@ var _ = Describe("Test application of the specified definition version", func()
|
||||
Expect(k8sClient.Patch(ctx, &app, client.Merge)).Should(HaveOccurred())
|
||||
})
|
||||
|
||||
PIt("Test deploy application which specify the name of component", func() {
|
||||
It("Test deploy application which specify the name of component", func() {
|
||||
compName := "job"
|
||||
app := v1beta1.Application{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -352,7 +352,7 @@ var _ = Describe("Test application of the specified definition version", func()
|
||||
}, 30*time.Second, 3*time.Second).Should(Succeed())
|
||||
})
|
||||
|
||||
PIt("Test deploy application which containing helm module", func() {
|
||||
It("Test deploy application which containing helm module", func() {
|
||||
var (
|
||||
appName = "test-helm"
|
||||
compName = "worker"
|
||||
@@ -513,7 +513,7 @@ var _ = Describe("Test application of the specified definition version", func()
|
||||
}, 120*time.Second, 5*time.Second).Should(BeTrue())
|
||||
})
|
||||
|
||||
PIt("Test deploy application which containing kube module", func() {
|
||||
It("Test deploy application which containing kube module", func() {
|
||||
var (
|
||||
appName = "test-kube-app"
|
||||
compName = "worker"
|
||||
@@ -686,7 +686,7 @@ var _ = Describe("Test application of the specified definition version", func()
|
||||
})
|
||||
|
||||
// refer to https://github.com/oam-dev/kubevela/discussions/1810#discussioncomment-914295
|
||||
PIt("Test k8s resources created by application whether with correct label", func() {
|
||||
It("Test k8s resources created by application whether with correct label", func() {
|
||||
var (
|
||||
appName = "test-resources-labels"
|
||||
compName = "web"
|
||||
@@ -708,7 +708,7 @@ var _ = Describe("Test application of the specified definition version", func()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
exposeV2.Spec.Schematic.CUE.Template = exposeV2Templae
|
||||
exposeV2.Spec.Schematic.CUE.Template = exposeV2Template
|
||||
return k8sClient.Update(ctx, exposeV2)
|
||||
}, 15*time.Second, time.Second).Should(BeNil())
|
||||
|
||||
@@ -1157,7 +1157,7 @@ parameter: {
|
||||
}
|
||||
`
|
||||
|
||||
var exposeV2Templae = `
|
||||
var exposeV2Template = `
|
||||
outputs: service: {
|
||||
apiVersion: "v1"
|
||||
kind: "Service"
|
||||
|
||||
@@ -208,7 +208,7 @@ var _ = Describe("ComponentDefinition Normal tests", func() {
|
||||
}, 15*time.Second, time.Second).Should(BeNil())
|
||||
|
||||
newTd := oldTd.DeepCopy()
|
||||
newTd.Spec.Schematic.CUE.Template = exposeV2Templae
|
||||
newTd.Spec.Schematic.CUE.Template = exposeV2Template
|
||||
Expect(k8sClient.Create(ctx, newTd)).Should(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user