Skip to content

Commit

Permalink
Fixing e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianZaccaria committed Nov 7, 2023
1 parent 1327da7 commit 6c9d706
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (gr *GenericResources) Cleanup(aw *arbv1.AppWrapper, awr *arbv1.AppWrapperG
}

// Get the resource to see if it exists in the AppWrapper namespace
labelSelector := fmt.Sprintf("%s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace)
labelSelector := fmt.Sprintf("%s=%s, %s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace, resourceName, unstruct.GetName())
inEtcd, err := dclient.Resource(rsrc).Namespace(aw.Namespace).List(context.Background(), metav1.ListOptions{LabelSelector: labelSelector})
if err != nil {
return name, gvk, err
Expand Down Expand Up @@ -310,7 +310,7 @@ func (gr *GenericResources) SyncQueueJob(aw *arbv1.AppWrapper, awr *arbv1.AppWra
}

// Get the resource to see if it exists
labelSelector := fmt.Sprintf("%s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace)
labelSelector := fmt.Sprintf("%s=%s, %s=%s, %s=%s", appwrapperJobLabelName, aw.Name, appwrapperJobLabelNamespace, aw.Namespace, resourceName, unstruct.GetName())
inEtcd, err := dclient.Resource(rsrc).List(context.Background(), metav1.ListOptions{LabelSelector: labelSelector})
if err != nil {
return []*v1.Pod{}, err
Expand Down
20 changes: 1 addition & 19 deletions test/e2e/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,32 +200,14 @@ var _ = Describe("AppWrapper E2E Test", func() {
appwrappersPtr := &appwrappers
defer cleanupTestObjectsPtr(context, appwrappersPtr)

aw := createDeploymentAW(context, "aw-deployment-3", "test")
aw := createDeploymentAW(context, "aw-deployment-3")
appwrappers = append(appwrappers, aw)

fmt.Fprintf(GinkgoWriter, "[e2e] Awaiting %d pods running for AW %s.\n", aw.Spec.SchedSpec.MinAvailable, aw.Name)
err := waitAWPodsReady(context, aw)
Expect(err).NotTo(HaveOccurred())
})

It("Create Two AppWrappers Same Name Different Namespaces - Deployment Only - 3 Pods Each", func() {
fmt.Fprintf(os.Stdout, "[e2e] Create Two AppWrappers Same Name Different Namespaces - Deployment Only 3 Pods Each - Started.\n")
context := initTestContext()
var appwrappers []*arbv1.AppWrapper
appwrappersPtr := &appwrappers
defer cleanupTestObjectsPtr(context, appwrappersPtr)

namespaces := []string{"nstest1", "nstest2"}
for _, ns := range namespaces {
aw := createDeploymentAW(context, "aw-deployment-3", ns)
appwrappers = append(appwrappers, aw)

fmt.Fprintf(GinkgoWriter, "[e2e] Awaiting %d pods running for AW %s in namespace %s.\n", aw.Spec.SchedSpec.MinAvailable, aw.Name, ns)
err := waitAWPodsReady(context, aw)
Expect(err).NotTo(HaveOccurred())
}
})

It("Create AppWrapper - Generic Deployment Only - 3 pods", func() {
fmt.Fprintf(os.Stdout, "[e2e] Create AppWrapper - Generic Deployment Only - 3 pods - Started.\n")
context := initTestContext()
Expand Down
11 changes: 6 additions & 5 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func initTestContext() *context {
Name: cxt.namespace,
},
}, metav1.CreateOptions{})

// Expect(err).NotTo(HaveOccurred())

/* _, err = cxt.kubeclient.SchedulingV1beta1().PriorityClasses().Create(gcontext.Background(), &schedv1.PriorityClass{
Expand Down Expand Up @@ -646,8 +647,8 @@ func createJobAWWithInitContainer(context *context, name string, requeuingTimeIn
return appwrapper
}

func createDeploymentAW(context *context, name string, namespace string) *arbv1.AppWrapper {
rb := []byte(fmt.Sprintf(`{"apiVersion": "apps/v1",
func createDeploymentAW(context *context, name string) *arbv1.AppWrapper {
rb := []byte(`{"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "aw-deployment-3",
Expand Down Expand Up @@ -686,13 +687,13 @@ func createDeploymentAW(context *context, name string, namespace string) *arbv1.
]
}
}
}} `, namespace))
}} `)
var schedSpecMin int = 3

aw := &arbv1.AppWrapper{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Namespace: context.namespace,
},
Spec: arbv1.AppWrapperSpec{
SchedSpec: arbv1.SchedulingSpecTemplate{
Expand All @@ -711,7 +712,7 @@ func createDeploymentAW(context *context, name string, namespace string) *arbv1.
},
}

appwrapper, err := context.karclient.WorkloadV1beta1().AppWrappers(namespace).Create(context.ctx, aw, metav1.CreateOptions{})
appwrapper, err := context.karclient.WorkloadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

return appwrapper
Expand Down

0 comments on commit 6c9d706

Please sign in to comment.