Skip to content

Commit 851164e

Browse files
committed
Create OLM upgrade e2e scenario using codeflare SDK
1 parent c372769 commit 851164e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

test/e2e/olm_upgrade_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ func TestMNISTRayClusterUp(t *testing.T) {
4242
test.T().Parallel()
4343
if os.Getenv("RUN_OLM_TESTS") == "true" {
4444
// Create a namespace
45-
namespace := CreateTestNamespaceWithName(test, namespaceName)
45+
namespace = CreateTestNamespaceWithName(test, namespaceName)
4646
test.T().Logf("Created namespace %s successfully", namespace.Name)
4747

48+
// Delete namespace only if test failed
49+
defer func() {
50+
if t.Failed() {
51+
DeleteTestNamespace(test, namespaceName)
52+
}
53+
}()
54+
4855
// Test configuration
4956
config := &corev1.ConfigMap{
5057
TypeMeta: metav1.TypeMeta{
@@ -212,6 +219,9 @@ func TestMnistJobSubmit(t *testing.T) {
212219
test.T().Parallel()
213220
if os.Getenv("RUN_OLM_TESTS") == "true" {
214221

222+
//delete the namespace after test complete
223+
defer DeleteTestNamespace(test, namespaceName)
224+
215225
// Test configuration
216226
config := &corev1.ConfigMap{
217227
TypeMeta: metav1.TypeMeta{
@@ -315,6 +325,7 @@ func TestMnistJobSubmit(t *testing.T) {
315325
// Assert the job has completed successfully
316326
test.Expect(GetJob(test, job.Namespace, job.Name)).
317327
To(WithTransform(ConditionStatus(batchv1.JobComplete), Equal(corev1.ConditionTrue)))
328+
318329
} else {
319330
test.T().Skip("Skipping OLM upgarde test because RUN_OLM_TESTS is not set")
320331
}

test/support/namespace.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,12 @@ func CreateTestNamespaceWithName(t Test, namespaceName string, options ...Option
7575

7676
return namespace
7777
}
78+
79+
func DeleteTestNamespace(t Test, namespaceName string) {
80+
t.T().Helper()
81+
propagationPolicy := metav1.DeletePropagationBackground
82+
err := t.Client().Core().CoreV1().Namespaces().Delete(t.Ctx(), namespaceName, metav1.DeleteOptions{
83+
PropagationPolicy: &propagationPolicy,
84+
})
85+
t.Expect(err).NotTo(gomega.HaveOccurred())
86+
}

0 commit comments

Comments
 (0)