Skip to content

Commit 8751ca0

Browse files
authoredMay 31, 2024··
Unpack Job Creation Failure Test (#3297)
Extends an existing unit test to cover the scenario where an old, failed job missing the label added in later OLM versions is not found with the filtered list call, resulting in an 'AlreadyExists' error when the new job is created. Signed-off-by: Daniel Franz <[email protected]>
1 parent 37dcff4 commit 8751ca0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎pkg/controller/bundle/bundle_unpacker_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -1218,14 +1218,15 @@ func TestConfigMapUnpacker(t *testing.T) {
12181218
},
12191219
},
12201220
{
1221-
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReason",
1221+
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReasonNoLabel",
12221222
fields: fields{
12231223
objs: []runtime.Object{
12241224
&batchv1.Job{
12251225
ObjectMeta: metav1.ObjectMeta{
12261226
Name: pathHash,
12271227
Namespace: "ns-a",
1228-
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
1228+
//omit the "operatorframework.io/bundle-unpack-ref" label
1229+
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
12291230
OwnerReferences: []metav1.OwnerReference{
12301231
{
12311232
APIVersion: "v1",
@@ -1442,6 +1443,9 @@ func TestConfigMapUnpacker(t *testing.T) {
14421443
},
14431444
},
14441445
expected: expected{
1446+
// If job is not found due to missing "operatorframework.io/bundle-unpack-ref" label,
1447+
// we will get an 'AlreadyExists' error in this test when the new job is created
1448+
err: nil,
14451449
res: &BundleUnpackResult{
14461450
name: pathHash,
14471451
BundleLookup: &operatorsv1alpha1.BundleLookup{
@@ -1474,7 +1478,7 @@ func TestConfigMapUnpacker(t *testing.T) {
14741478
ObjectMeta: metav1.ObjectMeta{
14751479
Name: pathHash,
14761480
Namespace: "ns-a",
1477-
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
1481+
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
14781482
OwnerReferences: []metav1.OwnerReference{
14791483
{
14801484
APIVersion: "v1",

0 commit comments

Comments
 (0)
Please sign in to comment.