@@ -42,9 +42,16 @@ func TestMNISTRayClusterUp(t *testing.T) {
42
42
test .T ().Parallel ()
43
43
if os .Getenv ("RUN_OLM_TESTS" ) == "true" {
44
44
// Create a namespace
45
- namespace : = CreateTestNamespaceWithName (test , namespaceName )
45
+ namespace = CreateTestNamespaceWithName (test , namespaceName )
46
46
test .T ().Logf ("Created namespace %s successfully" , namespace .Name )
47
47
48
+ // Delete namespace only if test failed
49
+ defer func () {
50
+ if t .Failed () {
51
+ DeleteTestNamespace (test , namespaceName )
52
+ }
53
+ }()
54
+
48
55
// Test configuration
49
56
config := & corev1.ConfigMap {
50
57
TypeMeta : metav1.TypeMeta {
@@ -212,6 +219,9 @@ func TestMnistJobSubmit(t *testing.T) {
212
219
test .T ().Parallel ()
213
220
if os .Getenv ("RUN_OLM_TESTS" ) == "true" {
214
221
222
+ //delete the namespace after test complete
223
+ defer DeleteTestNamespace (test , namespaceName )
224
+
215
225
// Test configuration
216
226
config := & corev1.ConfigMap {
217
227
TypeMeta : metav1.TypeMeta {
@@ -315,6 +325,7 @@ func TestMnistJobSubmit(t *testing.T) {
315
325
// Assert the job has completed successfully
316
326
test .Expect (GetJob (test , job .Namespace , job .Name )).
317
327
To (WithTransform (ConditionStatus (batchv1 .JobComplete ), Equal (corev1 .ConditionTrue )))
328
+
318
329
} else {
319
330
test .T ().Skip ("Skipping OLM upgarde test because RUN_OLM_TESTS is not set" )
320
331
}
0 commit comments