@@ -431,8 +431,41 @@ var _ = Describe("[rfe_id:27368][performance]", func() {
431431 })
432432
433433 Context ("Verify API Conversions" , func () {
434- It ("[test_id:35887] Verifies v1 <-> v1alpha1 conversions" , func () {
434+ verifyV2V1 := func () {
435+ By ("Checking v2 -> v1 conversion" )
436+ v1Profile := & performancev1.PerformanceProfile {}
437+ key := types.NamespacedName {
438+ Name : profile .Name ,
439+ Namespace : profile .Namespace ,
440+ }
441+
442+ err := testclient .Client .Get (context .TODO (), key , v1Profile )
443+ Expect (err ).ToNot (HaveOccurred (), "Failed getting v1Profile" )
444+ Expect (verifyV2Conversion (profile , v1Profile )).ToNot (HaveOccurred ())
435445
446+ By ("Checking v1 -> v2 conversion" )
447+ v1Profile .Name = "v1"
448+ v1Profile .ResourceVersion = ""
449+ v1Profile .Spec .NodeSelector = map [string ]string {"v1/v1" : "v1" }
450+ Expect (testclient .Client .Create (context .TODO (), v1Profile )).ToNot (HaveOccurred ())
451+
452+ key = types.NamespacedName {
453+ Name : v1Profile .Name ,
454+ Namespace : v1Profile .Namespace ,
455+ }
456+
457+ defer func () {
458+ Expect (testclient .Client .Delete (context .TODO (), v1Profile )).ToNot (HaveOccurred ())
459+ Expect (profiles .WaitForDeletion (key , 60 * time .Second )).ToNot (HaveOccurred ())
460+ }()
461+
462+ v2Profile := & performancev2.PerformanceProfile {}
463+ err = testclient .GetWithRetry (context .TODO (), key , v2Profile )
464+ Expect (err ).ToNot (HaveOccurred (), "Failed getting v2Profile" )
465+ Expect (verifyV2Conversion (v2Profile , v1Profile )).ToNot (HaveOccurred ())
466+ }
467+
468+ verifyV1VAlpha1 := func () {
436469 By ("Acquiring the tests profile as a v1 profile" )
437470 v1Profile := & performancev1.PerformanceProfile {}
438471 key := types.NamespacedName {
@@ -457,7 +490,7 @@ var _ = Describe("[rfe_id:27368][performance]", func() {
457490 By ("Checking v1alpha1 -> v1 conversion" )
458491 v1alpha1Profile .Name = "v1alpha"
459492 v1alpha1Profile .ResourceVersion = ""
460- v1alpha1Profile .Spec .NodeSelector = map [string ]string {"test " : "test " }
493+ v1alpha1Profile .Spec .NodeSelector = map [string ]string {"v1alpha/v1alpha " : "v1alpha " }
461494 Expect (testclient .Client .Create (context .TODO (), v1alpha1Profile )).ToNot (HaveOccurred ())
462495
463496 key = types.NamespacedName {
@@ -474,41 +507,49 @@ var _ = Describe("[rfe_id:27368][performance]", func() {
474507 err = testclient .GetWithRetry (context .TODO (), key , v1Profile )
475508 Expect (err ).ToNot (HaveOccurred (), "Failed getting v1profile" )
476509 Expect (verifyV1alpha1Conversion (v1alpha1Profile , v1Profile )).ToNot (HaveOccurred ())
477- })
478-
479- It ("[test_id:35888] Verifies v1 <-> v2 conversions" , func () {
480-
481- By ("Checking v2 -> v1 conversion" )
482- v1Profile := & performancev1.PerformanceProfile {}
483- key := types.NamespacedName {
484- Name : profile .Name ,
485- Namespace : profile .Namespace ,
486- }
487-
488- err := testclient .Client .Get (context .TODO (), key , v1Profile )
489- Expect (err ).ToNot (HaveOccurred (), "Failed getting v1Profile" )
490- Expect (verifyV2Conversion (profile , v1Profile )).ToNot (HaveOccurred ())
491-
492- By ("Checking v1 -> v2 conversion" )
493- v1Profile .Name = "v1"
494- v1Profile .ResourceVersion = ""
495- v1Profile .Spec .NodeSelector = map [string ]string {"test" : "test" }
496- Expect (testclient .Client .Create (context .TODO (), v1Profile )).ToNot (HaveOccurred ())
510+ }
497511
498- key = types.NamespacedName {
499- Name : v1Profile .Name ,
500- Namespace : v1Profile .Namespace ,
501- }
512+ When ("the performance profile does not contain NUMA field" , func () {
513+ BeforeEach (func () {
514+ key := types.NamespacedName {
515+ Name : profile .Name ,
516+ Namespace : profile .Namespace ,
517+ }
518+ err := testclient .Client .Get (context .TODO (), key , profile )
519+ Expect (err ).ToNot (HaveOccurred (), "Failed getting v1Profile" )
520+
521+ profile .Name = "without-numa"
522+ profile .ResourceVersion = ""
523+ profile .Spec .NodeSelector = map [string ]string {"withoutNUMA/withoutNUMA" : "withoutNUMA" }
524+ profile .Spec .NUMA = nil
525+
526+ err = testclient .Client .Create (context .TODO (), profile )
527+ Expect (err ).ToNot (HaveOccurred (), "Failed to create profile without NUMA" )
528+ })
529+
530+ AfterEach (func () {
531+ Expect (testclient .Client .Delete (context .TODO (), profile )).ToNot (HaveOccurred ())
532+ Expect (profiles .WaitForDeletion (types.NamespacedName {
533+ Name : profile .Name ,
534+ Namespace : profile .Namespace ,
535+ }, 60 * time .Second )).ToNot (HaveOccurred ())
536+ })
537+
538+ It ("Verifies v1 <-> v1alpha1 conversions" , func () {
539+ verifyV1VAlpha1 ()
540+ })
541+
542+ It ("Verifies v1 <-> v2 conversions" , func () {
543+ verifyV2V1 ()
544+ })
545+ })
502546
503- defer func () {
504- Expect (testclient .Client .Delete (context .TODO (), v1Profile )).ToNot (HaveOccurred ())
505- Expect (profiles .WaitForDeletion (key , 60 * time .Second )).ToNot (HaveOccurred ())
506- }()
547+ It ("[test_id:35887] Verifies v1 <-> v1alpha1 conversions" , func () {
548+ verifyV1VAlpha1 ()
549+ })
507550
508- v2Profile := & performancev2.PerformanceProfile {}
509- err = testclient .GetWithRetry (context .TODO (), key , v2Profile )
510- Expect (err ).ToNot (HaveOccurred (), "Failed getting v2Profile" )
511- Expect (verifyV2Conversion (v2Profile , v1Profile )).ToNot (HaveOccurred ())
551+ It ("[test_id:35888] Verifies v1 <-> v2 conversions" , func () {
552+ verifyV2V1 ()
512553 })
513554 })
514555})
0 commit comments