Skip to content

Commit d8fbfcc

Browse files
Crumbyryanemerson
authored andcommitted
Merge TestSpecImage and TestCustomImage
1 parent 15e2beb commit d8fbfcc

File tree

2 files changed

+14
-44
lines changed

2 files changed

+14
-44
lines changed

test/e2e/infinispan/custom_image_test.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ package infinispan
22

33
import (
44
"context"
5-
"strconv"
65
"testing"
76

87
ispnv1 "github.com/infinispan/infinispan-operator/api/v1"
9-
"github.com/infinispan/infinispan-operator/pkg/infinispan/version"
108
"github.com/infinispan/infinispan-operator/pkg/kubernetes"
119
"github.com/infinispan/infinispan-operator/pkg/reconcile/pipeline/infinispan/handler/provision"
1210
tutils "github.com/infinispan/infinispan-operator/test/e2e/utils"
@@ -20,30 +18,31 @@ func TestCustomImage(t *testing.T) {
2018
t.Parallel()
2119
defer testKube.CleanNamespaceAndLogOnPanic(t, tutils.Namespace)
2220

23-
var operand version.Operand
24-
versionManager := tutils.VersionManager()
25-
// Attempting to use latest Infinispan Server image while having version set to different major will result in misconfiguration by Operator
26-
if tutils.OperandVersion != "" {
27-
operand, _ = versionManager.WithRef(tutils.OperandVersion)
28-
} else {
29-
operand = versionManager.Latest()
30-
}
31-
img := "quay.io/infinispan/server:" + strconv.FormatUint(operand.UpstreamVersion.Major, 10) + "." + strconv.FormatUint(operand.UpstreamVersion.Minor, 10)
21+
// Get the two latest Operands that share the same major/minor version, otherwise we'll hit incompatibility issue
22+
customOperand, versionOperand := specImageOperands()
3223

24+
// Use customerOperand (previous release) as a custom image and spec.version of the latest release in the stream
3325
spec := tutils.DefaultSpec(t, testKube, func(i *ispnv1.Infinispan) {
34-
i.Spec.Image = pointer.String(img)
26+
i.Spec.Image = pointer.String(customOperand.Image)
27+
i.Spec.Version = versionOperand.Ref()
3528
})
3629

3730
testKube.CreateInfinispan(spec, tutils.Namespace)
3831
testKube.WaitForInfinispanPods(1, tutils.SinglePodTimeout, spec.Name, tutils.Namespace)
32+
3933
ispn := testKube.WaitForInfinispanCondition(spec.Name, spec.Namespace, ispnv1.ConditionWellFormed)
40-
assert.Equal(t, img, ispn.Status.Operand.Image)
34+
35+
assert.True(t, ispn.Status.Operand.CustomImage)
36+
assert.Equal(t, customOperand.Image, ispn.Status.Operand.Image)
37+
assert.Equal(t, versionOperand.Ref(), ispn.Status.Operand.Version)
38+
assert.Equal(t, ispnv1.OperandPhaseRunning, ispn.Status.Operand.Phase)
4139

4240
ss := &appsv1.StatefulSet{}
4341
tutils.ExpectNoError(testKube.Kubernetes.Client.Get(context.TODO(), types.NamespacedName{Namespace: spec.Namespace, Name: spec.GetStatefulSetName()}, ss))
4442
container := kubernetes.GetContainer(provision.InfinispanContainer, &ss.Spec.Template.Spec)
43+
4544
// Ensure that no SS rolling upgrade is executed as the default test Operand is marked as a CVE release
4645
// https://github.com/infinispan/infinispan-operator/issues/1817
4746
assert.Equal(t, int64(1), ss.Generation)
48-
assert.Equal(t, img, container.Image)
47+
assert.Equal(t, customOperand.Image, container.Image)
4948
}

test/e2e/infinispan/upgrade_operand_test.go

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,36 +286,6 @@ func TestOperandCVEHotRodRolling(t *testing.T) {
286286
genericTestForContainerUpdated(*spec, modifier, verifier)
287287
}
288288

289-
func TestSpecImage(t *testing.T) {
290-
defer testKube.CleanNamespaceAndLogOnPanic(t, tutils.Namespace)
291-
292-
// Create Infinispan Cluster using a newer Operand version (versionOperand),
293-
// but using the image of an older Operand (imageOperand).
294-
// Ensures that creating a cluster with an initial spec.image value does not cause infinite StatefulSet updates.
295-
// The two version are chosen to be the last possible versions having the same major and minor.
296-
imageOperand, versionOperand := specImageOperands()
297-
spec := tutils.DefaultSpec(t, testKube, func(i *ispnv1.Infinispan) {
298-
i.Spec.Image = pointer.String(imageOperand.Image)
299-
i.Spec.Version = versionOperand.Ref()
300-
})
301-
302-
statusVersionRef := versionOperand.Ref()
303-
if tutils.OperandVersion != "" {
304-
statusVersionRef = tutils.OperandVersion
305-
}
306-
307-
testKube.CreateInfinispan(spec, tutils.Namespace)
308-
testKube.WaitForInfinispanPods(1, tutils.SinglePodTimeout, spec.Name, tutils.Namespace)
309-
testKube.WaitForInfinispanCondition(spec.Name, spec.Namespace, ispnv1.ConditionWellFormed)
310-
testKube.WaitForInfinispanState(spec.Name, spec.Namespace, func(i *ispnv1.Infinispan) bool {
311-
return i.IsConditionTrue(ispnv1.ConditionWellFormed) &&
312-
i.Status.Operand.CustomImage &&
313-
i.Status.Operand.Version == statusVersionRef &&
314-
i.Status.Operand.Image == imageOperand.Image &&
315-
i.Status.Operand.Phase == ispnv1.OperandPhaseRunning
316-
})
317-
}
318-
319289
func TestSpecImageUpdate(t *testing.T) {
320290
defer testKube.CleanNamespaceAndLogOnPanic(t, tutils.Namespace)
321291

@@ -407,6 +377,7 @@ func TestSpecImageUpdate(t *testing.T) {
407377
assert.EqualValues(t, 1, ss.Status.ObservedGeneration)
408378
}
409379

380+
// specImageOperands() returns two latest Operands with the matching major/minor version
410381
func specImageOperands() (*version.Operand, *version.Operand) {
411382
operands := tutils.VersionManager().Operands
412383
length := len(operands)

0 commit comments

Comments
 (0)