Feat: optimize the e2e test case

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
barnettZQG
2022-07-29 19:29:38 +08:00
parent 2d6ad41afc
commit afa786a096
6 changed files with 34 additions and 23 deletions
@@ -955,6 +955,7 @@ options: {
Expect(err).Should(BeNil())
Expect(len(urls)).Should(Equal(len(endpoints)))
for i, e := range endpoints {
fmt.Println(e.String())
Expect(urls[i]).Should(Equal(e.String()))
}
})
+15 -10
View File
@@ -175,17 +175,22 @@ func (o *VelaPortForwardOptions) Init(ctx context.Context, cmd *cobra.Command, a
fmt.Println("The Service you specified does not exist, please select it from the list.")
}
}
if selectService == nil {
selectService, o.targetPort, err = AskToChooseOneService(services, len(o.Args) < 2)
if err != nil {
return err
if len(services) > 0 {
if selectService == nil {
selectService, o.targetPort, err = AskToChooseOneService(services, len(o.Args) < 2)
if err != nil {
return err
}
}
}
if selectService != nil {
o.targetResource.cluster = selectService.Cluster
o.targetResource.name = selectService.Object.GetName()
o.targetResource.namespace = selectService.Object.GetNamespace()
o.targetResource.kind = selectService.Object.GetKind()
if selectService != nil {
o.targetResource.cluster = selectService.Cluster
o.targetResource.name = selectService.Object.GetName()
o.targetResource.namespace = selectService.Object.GetNamespace()
o.targetResource.kind = selectService.Object.GetKind()
}
} else if o.ResourceName == "" {
// If users do not specify the resource name and there is no service, switch to query the pod
o.ResourceType = "pod"
}
}
@@ -9,7 +9,9 @@ spec:
type: webservice
properties:
image: crccheck/hello-world
port: 8000
ports:
- port: 8000
expose: true
traits:
- type: scaler
properties:
@@ -9,7 +9,9 @@ spec:
type: webservice
properties:
image: crccheck/hello-world
port: 8000
ports:
- port: 8000
expose: true
traits:
- type: scaler
properties:
@@ -9,20 +9,19 @@ spec:
type: webservice
properties:
image: crccheck/hello-world
port: 8000
ports:
- port: 8000
expose: true
policies:
- name: env-policy
type: env-binding
type: topology
properties:
envs:
- name: test
placement:
clusterSelector:
name: cluster-worker
clusters:
- cluster-worker
workflow:
steps:
- name: deploy-test
type: deploy2env
type: deploy
properties:
policy: env-policy
env: test
policies:
- env-policy
@@ -9,7 +9,9 @@ spec:
type: webservice
properties:
image: crccheck/hello-world
port: 8000
ports:
- port: 8000
expose: true
type: webservice
traits:
- type: rollout