-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OCPBUGS-6780: Add a test to expose cleanup issue with SSBs #295
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2795,3 +2795,75 @@ func TestScheduledSuiteTimeoutFail(t *testing.T) { | |
t.Fatal("The scan should have the timeout annotation") | ||
} | ||
} | ||
|
||
func TestUpdateScanSettingBindingRemovesScans(t *testing.T) { | ||
f := framework.Global | ||
t.Parallel() | ||
bindingName := framework.GetObjNameFromTest(t) | ||
cisProfileName := "ocp4-cis" | ||
moderateProfileName := "ocp4-moderate" | ||
|
||
// create a ssb with two profiles "ocp4-cis" and "ocp4-moderate" | ||
scanSettingBinding := compv1alpha1.ScanSettingBinding{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: bindingName, | ||
Namespace: f.OperatorNamespace, | ||
}, | ||
Profiles: []compv1alpha1.NamedObjectReference{ | ||
{ | ||
Name: cisProfileName, | ||
Kind: "Profile", | ||
APIGroup: "compliance.openshift.io/v1alpha1", | ||
}, | ||
{ | ||
Name: moderateProfileName, | ||
Kind: "Profile", | ||
APIGroup: "compliance.openshift.io/v1alpha1", | ||
}, | ||
}, | ||
SettingsRef: &compv1alpha1.NamedObjectReference{ | ||
Name: "default", | ||
Kind: "ScanSetting", | ||
APIGroup: "compliance.openshift.io/v1alpha1", | ||
}, | ||
} | ||
err := f.Client.Create(context.TODO(), &scanSettingBinding, nil) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer f.Client.Delete(context.TODO(), &scanSettingBinding) | ||
|
||
err = f.WaitForSuiteScansStatus(f.OperatorNamespace, scanSettingBinding.Name, compv1alpha1.PhaseDone, compv1alpha1.ResultNonCompliant) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
f.AssertScanExists(cisProfileName, f.OperatorNamespace) | ||
f.AssertScanExists(moderateProfileName, f.OperatorNamespace) | ||
|
||
update := &compv1alpha1.ScanSettingBinding{} | ||
err = f.Client.Get(context.TODO(), types.NamespacedName{Namespace: f.OperatorNamespace, Name: scanSettingBinding.Name}, update) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
update.Profiles = []compv1alpha1.NamedObjectReference{ | ||
{ | ||
Name: cisProfileName, | ||
Kind: "Profile", | ||
APIGroup: "compliance.openshift.io/v1alpha1", | ||
}, | ||
} | ||
err = f.Client.Update(context.TODO(), update) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// We might need a different utility to rerun a suite instead of scan | ||
err = f.ReRunScan(scanSettingBinding.Name, f.OperatorNamespace) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails because the scan name isn't the binding name. Need to find a better way to assert this... Or maybe we just go right into the assertions below about the scans. I guess it depends on where the cleanup happens. If it happens in the SSB controller, we probably won't need to rescan. I'm open to recommendations here. |
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
f.AssertScanExists(cisProfileName, f.OperatorNamespace) | ||
f.AssertScanDoesNotExists(moderateProfileName, f.OperatorNamespace) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will conflict with a couple other patches I have that need this. Just a heads up for the rebase.