From 2436da3e23232cbad7a5a6d3d719c09d8494c6a2 Mon Sep 17 00:00:00 2001 From: taimurhafeez Date: Wed, 18 Feb 2026 11:36:34 +0000 Subject: [PATCH 1/3] Enhanced TestScanTailoredProfileIsDeprecated to cover case when TailoredProfile extends a Profile that is marked deprecated --- tests/e2e/parallel/main_test.go | 118 ++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 4 deletions(-) diff --git a/tests/e2e/parallel/main_test.go b/tests/e2e/parallel/main_test.go index 9a3f3e23a2..a8b5b80c2e 100644 --- a/tests/e2e/parallel/main_test.go +++ b/tests/e2e/parallel/main_test.go @@ -793,6 +793,7 @@ func TestScanTailoredProfileIsDeprecated(t *testing.T) { t.Parallel() f := framework.Global + // SCENARIO 1: TailoredProfile itself is marked deprecated via annotation tpName := "test-tailored-profile-is-deprecated" tp := &compv1alpha1.TailoredProfile{ ObjectMeta: metav1.ObjectMeta{ @@ -854,6 +855,115 @@ func TestScanTailoredProfileIsDeprecated(t *testing.T) { if err = f.WaitForScanStatus(f.OperatorNamespace, scanName, compv1alpha1.PhaseDone); err != nil { t.Fatal(err) } + + // SCENARIO 2: TailoredProfile extends a deprecated Profile (covers downstream test case 81235) + // Create a ProfileBundle that will generate profiles + deprecatedPBName := "test-deprecated-pb" + deprecatedPB := &compv1alpha1.ProfileBundle{ + ObjectMeta: metav1.ObjectMeta{ + Name: deprecatedPBName, + Namespace: f.OperatorNamespace, + }, + Spec: compv1alpha1.ProfileBundleSpec{ + ContentImage: contentImagePath, + ContentFile: framework.OcpContentFile, + }, + } + err = f.Client.Create(context.TODO(), deprecatedPB, nil) + if err != nil { + t.Fatal(err) + } + defer f.Client.Delete(context.TODO(), deprecatedPB) + + // Wait for the ProfileBundle to be ready and create profiles + err = f.WaitForProfileBundleStatus(deprecatedPBName, compv1alpha1.DataStreamValid) + if err != nil { + t.Fatal(err) + } + + // Find one of the profiles created by the ProfileBundle and annotate it as deprecated + // Using ocp4-cis as it should be available in the standard content + deprecatedProfileName := deprecatedPBName + "-cis" + deprecatedProfile := &compv1alpha1.Profile{} + err = f.Client.Get(context.TODO(), types.NamespacedName{Name: deprecatedProfileName, Namespace: f.OperatorNamespace}, deprecatedProfile) + if err != nil { + t.Fatal(err) + } + + // Add deprecated annotation to the profile + deprecatedProfileCopy := deprecatedProfile.DeepCopy() + if deprecatedProfileCopy.Annotations == nil { + deprecatedProfileCopy.Annotations = make(map[string]string) + } + deprecatedProfileCopy.Annotations[compv1alpha1.ProfileStatusAnnotation] = "deprecated" + err = f.Client.Update(context.TODO(), deprecatedProfileCopy) + if err != nil { + t.Fatal(err) + } + + // Create a TailoredProfile that extends the deprecated Profile + tpExtendsDeprecatedName := "test-tp-extends-deprecated" + tpExtendsDeprecated := &compv1alpha1.TailoredProfile{ + ObjectMeta: metav1.ObjectMeta{ + Name: tpExtendsDeprecatedName, + Namespace: f.OperatorNamespace, + // NO deprecation annotation on the TailoredProfile itself + }, + Spec: compv1alpha1.TailoredProfileSpec{ + Extends: deprecatedProfileName, + Title: "TestScanTailoredProfileExtendsDeprecated", + Description: "TestScanTailoredProfileExtendsDeprecated", + // Not specifying EnableRules - just extending the profile as-is to test deprecation + }, + } + err = f.Client.Create(context.TODO(), tpExtendsDeprecated, nil) + if err != nil { + t.Fatal(err) + } + defer f.Client.Delete(context.TODO(), tpExtendsDeprecated) + + // Wait for TailoredProfile to be ready before creating SSB + err = f.WaitForTailoredProfileStatus(f.OperatorNamespace, tpExtendsDeprecatedName, compv1alpha1.TailoredProfileStateReady) + if err != nil { + t.Fatal(err) + } + + // Create SSB for second scenario + suiteName2 := framework.GetObjNameFromTest(t) + "-extends-deprecated" + ssb2 := &compv1alpha1.ScanSettingBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: suiteName2, + Namespace: f.OperatorNamespace, + }, + Profiles: []compv1alpha1.NamedObjectReference{ + { + APIGroup: "compliance.openshift.io/v1alpha1", + Kind: "TailoredProfile", + Name: tpExtendsDeprecatedName, + }, + }, + SettingsRef: &compv1alpha1.NamedObjectReference{ + APIGroup: "compliance.openshift.io/v1alpha1", + Kind: "ScanSetting", + Name: "default", + }, + } + err = f.Client.Create(context.TODO(), ssb2, nil) + if err != nil { + t.Fatal(err) + } + defer f.Client.Delete(context.TODO(), ssb2) + + // Wait for deprecation warning for the Profile being extended + scanName2 := tpExtendsDeprecatedName + if err = f.WaitForProfileDeprecatedWarning(t, scanName2, deprecatedProfileName); err != nil { + t.Fatal(err) + } + + // Verify scan completes successfully + if err = f.WaitForScanStatus(f.OperatorNamespace, scanName2, compv1alpha1.PhaseDone); err != nil { + t.Fatal(err) + } } func TestScanTailoredProfileHasDuplicateVariables(t *testing.T) { @@ -1014,10 +1124,10 @@ func TestSingleScanWithStorageSucceeds(t *testing.T) { if err != nil { t.Fatal(err) } - err = f.AssertARFReportExistsInPVC(scanName, f.OperatorNamespace) - if err != nil { - t.Fatal(err) - } + // err = f.AssertARFReportExistsInPVC(scanName, f.OperatorNamespace) + // if err != nil { + // t.Fatal(err) + // } } func TestScanWithUnexistentResourceFails(t *testing.T) { From b9ff8fc1f6405ee594fdc887e352369ad6b12c38 Mon Sep 17 00:00:00 2001 From: taimurhafeez Date: Wed, 18 Feb 2026 11:43:49 +0000 Subject: [PATCH 2/3] undone some unintended changes --- tests/e2e/parallel/main_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/e2e/parallel/main_test.go b/tests/e2e/parallel/main_test.go index a8b5b80c2e..a3d7426720 100644 --- a/tests/e2e/parallel/main_test.go +++ b/tests/e2e/parallel/main_test.go @@ -856,7 +856,8 @@ func TestScanTailoredProfileIsDeprecated(t *testing.T) { t.Fatal(err) } - // SCENARIO 2: TailoredProfile extends a deprecated Profile (covers downstream test case 81235) + // SCENARIO 2: TailoredProfile extends a deprecated Profile - the TailoredProfile itself is not marked deprecated, + // but it should still trigger the deprecation warning because it extends a deprecated profile // Create a ProfileBundle that will generate profiles deprecatedPBName := "test-deprecated-pb" deprecatedPB := &compv1alpha1.ProfileBundle{ @@ -1124,10 +1125,10 @@ func TestSingleScanWithStorageSucceeds(t *testing.T) { if err != nil { t.Fatal(err) } - // err = f.AssertARFReportExistsInPVC(scanName, f.OperatorNamespace) - // if err != nil { - // t.Fatal(err) - // } + err = f.AssertARFReportExistsInPVC(scanName, f.OperatorNamespace) + if err != nil { + t.Fatal(err) + } } func TestScanWithUnexistentResourceFails(t *testing.T) { From f47951b9a9a984ad386721adf739eb92fef8aaa5 Mon Sep 17 00:00:00 2001 From: taimurhafeez Date: Wed, 20 May 2026 17:54:40 +0500 Subject: [PATCH 3/3] Addressed Reviews: Seperate scenarios & using dynamic profile bundle --- tests/e2e/parallel/main_test.go | 102 +++++++++++++------------------- 1 file changed, 42 insertions(+), 60 deletions(-) diff --git a/tests/e2e/parallel/main_test.go b/tests/e2e/parallel/main_test.go index a3d7426720..85425b0088 100644 --- a/tests/e2e/parallel/main_test.go +++ b/tests/e2e/parallel/main_test.go @@ -855,92 +855,76 @@ func TestScanTailoredProfileIsDeprecated(t *testing.T) { if err = f.WaitForScanStatus(f.OperatorNamespace, scanName, compv1alpha1.PhaseDone); err != nil { t.Fatal(err) } +} - // SCENARIO 2: TailoredProfile extends a deprecated Profile - the TailoredProfile itself is not marked deprecated, - // but it should still trigger the deprecation warning because it extends a deprecated profile - // Create a ProfileBundle that will generate profiles - deprecatedPBName := "test-deprecated-pb" - deprecatedPB := &compv1alpha1.ProfileBundle{ - ObjectMeta: metav1.ObjectMeta{ - Name: deprecatedPBName, - Namespace: f.OperatorNamespace, - }, - Spec: compv1alpha1.ProfileBundleSpec{ - ContentImage: contentImagePath, - ContentFile: framework.OcpContentFile, - }, - } - err = f.Client.Create(context.TODO(), deprecatedPB, nil) +func TestScanTailoredProfileExtendsDeprecatedProfile(t *testing.T) { + t.Parallel() + f := framework.Global + + pbName := framework.GetObjNameFromTest(t) + baselineImage := fmt.Sprintf("%s:%s", brokenContentImagePath, "deprecated_profile") + pb, err := f.CreateProfileBundle(pbName, baselineImage, framework.OcpContentFile) if err != nil { - t.Fatal(err) + t.Fatalf("failed to create ProfileBundle: %s", err) } - defer f.Client.Delete(context.TODO(), deprecatedPB) + defer f.Client.Delete(context.TODO(), pb) - // Wait for the ProfileBundle to be ready and create profiles - err = f.WaitForProfileBundleStatus(deprecatedPBName, compv1alpha1.DataStreamValid) - if err != nil { - t.Fatal(err) + if err := f.WaitForProfileBundleStatus(pbName, compv1alpha1.DataStreamValid); err != nil { + t.Fatalf("failed waiting for the ProfileBundle to become available: %s", err) } - // Find one of the profiles created by the ProfileBundle and annotate it as deprecated - // Using ocp4-cis as it should be available in the standard content - deprecatedProfileName := deprecatedPBName + "-cis" - deprecatedProfile := &compv1alpha1.Profile{} - err = f.Client.Get(context.TODO(), types.NamespacedName{Name: deprecatedProfileName, Namespace: f.OperatorNamespace}, deprecatedProfile) + profileList := &compv1alpha1.ProfileList{} + err = f.Client.List(context.TODO(), profileList, + client.InNamespace(f.OperatorNamespace), + client.MatchingLabels{compv1alpha1.ProfileBundleOwnerLabel: pbName}) if err != nil { - t.Fatal(err) + t.Fatalf("failed to list profiles for bundle %s: %s", pbName, err) } - // Add deprecated annotation to the profile - deprecatedProfileCopy := deprecatedProfile.DeepCopy() - if deprecatedProfileCopy.Annotations == nil { - deprecatedProfileCopy.Annotations = make(map[string]string) + var deprecatedProfileName string + for _, p := range profileList.Items { + if p.Annotations[compv1alpha1.ProfileStatusAnnotation] == "deprecated" { + deprecatedProfileName = p.Name + break + } } - deprecatedProfileCopy.Annotations[compv1alpha1.ProfileStatusAnnotation] = "deprecated" - err = f.Client.Update(context.TODO(), deprecatedProfileCopy) - if err != nil { - t.Fatal(err) + if deprecatedProfileName == "" { + t.Fatal("no deprecated profile found in the bundle") } - // Create a TailoredProfile that extends the deprecated Profile - tpExtendsDeprecatedName := "test-tp-extends-deprecated" - tpExtendsDeprecated := &compv1alpha1.TailoredProfile{ + tpName := framework.GetObjNameFromTest(t) + "-tp" + tp := &compv1alpha1.TailoredProfile{ ObjectMeta: metav1.ObjectMeta{ - Name: tpExtendsDeprecatedName, + Name: tpName, Namespace: f.OperatorNamespace, - // NO deprecation annotation on the TailoredProfile itself }, Spec: compv1alpha1.TailoredProfileSpec{ Extends: deprecatedProfileName, - Title: "TestScanTailoredProfileExtendsDeprecated", - Description: "TestScanTailoredProfileExtendsDeprecated", - // Not specifying EnableRules - just extending the profile as-is to test deprecation + Title: "TestScanTailoredProfileExtendsDeprecatedProfile", + Description: "TestScanTailoredProfileExtendsDeprecatedProfile", }, } - err = f.Client.Create(context.TODO(), tpExtendsDeprecated, nil) + err = f.Client.Create(context.TODO(), tp, nil) if err != nil { t.Fatal(err) } - defer f.Client.Delete(context.TODO(), tpExtendsDeprecated) + defer f.Client.Delete(context.TODO(), tp) - // Wait for TailoredProfile to be ready before creating SSB - err = f.WaitForTailoredProfileStatus(f.OperatorNamespace, tpExtendsDeprecatedName, compv1alpha1.TailoredProfileStateReady) - if err != nil { + if err = f.WaitForTailoredProfileStatus(f.OperatorNamespace, tpName, compv1alpha1.TailoredProfileStateReady); err != nil { t.Fatal(err) } - // Create SSB for second scenario - suiteName2 := framework.GetObjNameFromTest(t) + "-extends-deprecated" - ssb2 := &compv1alpha1.ScanSettingBinding{ + suiteName := framework.GetObjNameFromTest(t) + ssb := &compv1alpha1.ScanSettingBinding{ ObjectMeta: metav1.ObjectMeta{ - Name: suiteName2, + Name: suiteName, Namespace: f.OperatorNamespace, }, Profiles: []compv1alpha1.NamedObjectReference{ { APIGroup: "compliance.openshift.io/v1alpha1", Kind: "TailoredProfile", - Name: tpExtendsDeprecatedName, + Name: tpName, }, }, SettingsRef: &compv1alpha1.NamedObjectReference{ @@ -949,20 +933,18 @@ func TestScanTailoredProfileIsDeprecated(t *testing.T) { Name: "default", }, } - err = f.Client.Create(context.TODO(), ssb2, nil) + err = f.Client.Create(context.TODO(), ssb, nil) if err != nil { t.Fatal(err) } - defer f.Client.Delete(context.TODO(), ssb2) + defer f.Client.Delete(context.TODO(), ssb) - // Wait for deprecation warning for the Profile being extended - scanName2 := tpExtendsDeprecatedName - if err = f.WaitForProfileDeprecatedWarning(t, scanName2, deprecatedProfileName); err != nil { + scanName := tpName + if err = f.WaitForProfileDeprecatedWarning(t, scanName, deprecatedProfileName); err != nil { t.Fatal(err) } - // Verify scan completes successfully - if err = f.WaitForScanStatus(f.OperatorNamespace, scanName2, compv1alpha1.PhaseDone); err != nil { + if err = f.WaitForScanStatus(f.OperatorNamespace, scanName, compv1alpha1.PhaseDone); err != nil { t.Fatal(err) } }