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 3225574
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 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
19 changes: 14 additions & 5 deletions test/e2e/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,27 @@ var _ = Describe("AppWrapper E2E Test", func() {

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()

namespaces := []string{"test", "test2"}

contextMap := map[string]*context{
"test": initTestContext(),
"test2": initTestContext2(),
}

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)
ctx := contextMap[ns]
defer cleanupTestObjectsPtr(ctx, appwrappersPtr)

aw := createDeploymentAW(ctx, "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)
err := waitAWPodsReady(ctx, aw)
Expect(err).NotTo(HaveOccurred())
}
})
Expand Down
29 changes: 29 additions & 0 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 All @@ -114,6 +115,34 @@ func initTestContext() *context {
return cxt
}

func initTestContext2() *context {
enableNamespaceAsQueue, _ := strconv.ParseBool(os.Getenv("ENABLE_NAMESPACES_AS_QUEUE"))
cxt := &context{
namespace: "test2",
queues: []string{"q1", "q2"},
}

home := homeDir()
Expect(home).NotTo(Equal(""))

config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(home, ".kube", "config"))
Expect(err).NotTo(HaveOccurred())

cxt.karclient = versioned.NewForConfigOrDie(config)
cxt.kubeclient = kubernetes.NewForConfigOrDie(config)

cxt.enableNamespaceAsQueue = enableNamespaceAsQueue

_, err = cxt.kubeclient.CoreV1().Namespaces().Create(gcontext.Background(), &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: cxt.namespace,
},
}, metav1.CreateOptions{})

cxt.ctx = gcontext.Background()
return cxt
}

func cleanupTestContextExtendedTime(cxt *context, seconds time.Duration) {
// foreground := metav1.DeletePropagationForeground
/* err := cxt.kubeclient.CoreV1().Namespaces().Delete(gcontext.Background(), cxt.namespace, metav1.DeleteOptions{
Expand Down

0 comments on commit 3225574

Please sign in to comment.