Skip to content

Commit

Permalink
Unpack Job Creation Failure Test (#3297)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dtfranz authored May 31, 2024
1 parent 37dcff4 commit 8751ca0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/controller/bundle/bundle_unpacker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,14 +1218,15 @@ func TestConfigMapUnpacker(t *testing.T) {
},
},
{
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReason",
description: "CatalogSourcePresent/JobFailed/BundleLookupFailed/WithJobFailReasonNoLabel",
fields: fields{
objs: []runtime.Object{
&batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: pathHash,
Namespace: "ns-a",
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
//omit the "operatorframework.io/bundle-unpack-ref" label
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "v1",
Expand Down Expand Up @@ -1442,6 +1443,9 @@ func TestConfigMapUnpacker(t *testing.T) {
},
},
expected: expected{
// If job is not found due to missing "operatorframework.io/bundle-unpack-ref" label,
// we will get an 'AlreadyExists' error in this test when the new job is created
err: nil,
res: &BundleUnpackResult{
name: pathHash,
BundleLookup: &operatorsv1alpha1.BundleLookup{
Expand Down Expand Up @@ -1474,7 +1478,7 @@ func TestConfigMapUnpacker(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: pathHash,
Namespace: "ns-a",
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue, bundleUnpackRefLabel: pathHash},
Labels: map[string]string{install.OLMManagedLabelKey: install.OLMManagedLabelValue},
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "v1",
Expand Down

0 comments on commit 8751ca0

Please sign in to comment.