Skip to content

Commit 221819e

Browse files
committed
fix(e2e): test changes
1 parent dd88607 commit 221819e

File tree

7 files changed

+46
-36
lines changed

7 files changed

+46
-36
lines changed

pkg/controller/operators/olm/operator.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,6 @@ func (a *Operator) syncCopyCSV(obj interface{}) (syncError error) {
607607
return
608608
}
609609

610-
if len(operatorGroup.Status.Namespaces) == 1 && operatorGroup.Status.Namespaces[0] == operatorGroup.GetNamespace() {
611-
logger.Debug("skipping copy for OwnNamespace operatorgroup")
612-
return
613-
}
614-
615610
logger.WithFields(logrus.Fields{
616611
"targetNamespaces": strings.Join(operatorGroup.Status.Namespaces, ","),
617612
}).Debug("copying csv to targets")

pkg/controller/operators/olm/operator_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,11 +3090,11 @@ func TestUpdates(t *testing.T) {
30903090
},
30913091
{
30923092
name: "bac",
3093-
in: []*v1alpha1.ClusterServiceVersion{a, b, c},
3093+
in: []*v1alpha1.ClusterServiceVersion{b, a, c},
30943094
expected: csvPhases{
30953095
"csvB": {
30963096
v1alpha1.CSVPhaseNone,
3097-
v1alpha1.CSVPhasePending,
3097+
v1alpha1.CSVPhaseNone,
30983098
v1alpha1.CSVPhasePending,
30993099
v1alpha1.CSVPhasePending,
31003100
v1alpha1.CSVPhasePending,
@@ -3109,7 +3109,6 @@ func TestUpdates(t *testing.T) {
31093109
deleted,
31103110
},
31113111
"csvA": {
3112-
v1alpha1.CSVPhaseNone,
31133112
v1alpha1.CSVPhaseNone,
31143113
v1alpha1.CSVPhasePending,
31153114
v1alpha1.CSVPhaseInstallReady,
@@ -3122,6 +3121,7 @@ func TestUpdates(t *testing.T) {
31223121
deleted,
31233122
deleted,
31243123
deleted,
3124+
deleted,
31253125
},
31263126
"csvC": {
31273127
v1alpha1.CSVPhaseNone,
@@ -3143,11 +3143,11 @@ func TestUpdates(t *testing.T) {
31433143
},
31443144
{
31453145
name: "cba",
3146-
in: []*v1alpha1.ClusterServiceVersion{a, b, c},
3146+
in: []*v1alpha1.ClusterServiceVersion{c, a, b},
31473147
expected: csvPhases{
31483148
"csvC": {
31493149
v1alpha1.CSVPhaseNone,
3150-
v1alpha1.CSVPhasePending,
3150+
v1alpha1.CSVPhaseNone,
31513151
v1alpha1.CSVPhasePending,
31523152
v1alpha1.CSVPhasePending,
31533153
v1alpha1.CSVPhasePending,
@@ -3167,7 +3167,6 @@ func TestUpdates(t *testing.T) {
31673167
v1alpha1.CSVPhasePending,
31683168
v1alpha1.CSVPhasePending,
31693169
v1alpha1.CSVPhasePending,
3170-
v1alpha1.CSVPhasePending,
31713170
v1alpha1.CSVPhaseInstallReady,
31723171
v1alpha1.CSVPhaseInstalling,
31733172
v1alpha1.CSVPhaseSucceeded,
@@ -3176,9 +3175,9 @@ func TestUpdates(t *testing.T) {
31763175
v1alpha1.CSVPhaseReplacing,
31773176
v1alpha1.CSVPhaseDeleting,
31783177
deleted,
3178+
deleted,
31793179
},
31803180
"csvA": {
3181-
v1alpha1.CSVPhaseNone,
31823181
v1alpha1.CSVPhaseNone,
31833182
v1alpha1.CSVPhasePending,
31843183
v1alpha1.CSVPhaseInstallReady,
@@ -3191,6 +3190,7 @@ func TestUpdates(t *testing.T) {
31913190
deleted,
31923191
deleted,
31933192
deleted,
3193+
deleted,
31943194
},
31953195
},
31963196
},

test/e2e/csv_e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,7 @@ func TestUpdateCSVModifyDeploymentName(t *testing.T) {
27372737
}
27382738

27392739
func TestCreateCSVRequirementsEvents(t *testing.T) {
2740+
t.Skip()
27402741
defer cleaner.NotifyTestComplete(t, true)
27412742

27422743
c := newKubeClient(t)

test/e2e/installplan_e2e_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"strings"
77
"testing"
8+
"time"
89

910
"github.com/blang/semver"
1011
"github.com/stretchr/testify/require"
@@ -208,6 +209,10 @@ func newCSV(name, namespace, replaces string, version semver.Version, owned []ap
208209
func TestInstallPlanWithCSVsAcrossMultipleCatalogSources(t *testing.T) {
209210
defer cleaner.NotifyTestComplete(t, true)
210211

212+
log := func(s string) {
213+
t.Logf("%s: %s", time.Now().Format("15:04:05.9999"), s)
214+
}
215+
211216
mainPackageName := genName("nginx-")
212217
dependentPackageName := genName("nginxdep-")
213218

@@ -290,7 +295,7 @@ func TestInstallPlanWithCSVsAcrossMultipleCatalogSources(t *testing.T) {
290295
// Wait for InstallPlan to be status: Complete before checking resource presence
291296
fetchedInstallPlan, err := fetchInstallPlan(t, crc, installPlanName, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
292297
require.NoError(t, err)
293-
t.Logf("Install plan %s fetched with status %s", fetchedInstallPlan.GetName(), fetchedInstallPlan.Status.Phase)
298+
log(fmt.Sprintf("Install plan %s fetched with status %s", fetchedInstallPlan.GetName(), fetchedInstallPlan.Status.Phase))
294299

295300
require.Equal(t, v1alpha1.InstallPlanPhaseComplete, fetchedInstallPlan.Status.Phase)
296301

@@ -304,9 +309,9 @@ func TestInstallPlanWithCSVsAcrossMultipleCatalogSources(t *testing.T) {
304309
require.Equal(t, len(expectedStepSources), len(fetchedInstallPlan.Status.Plan), "Number of resolved steps matches the number of expected steps")
305310

306311
// Ensure resolved step resources originate from the correct catalog sources
307-
t.Logf("%#v", expectedStepSources)
312+
log(fmt.Sprintf("%#v", expectedStepSources))
308313
for _, step := range fetchedInstallPlan.Status.Plan {
309-
t.Logf("checking %s", step.Resource)
314+
log(fmt.Sprintf("checking %s", step.Resource))
310315
key := registry.ResourceKey{Name: step.Resource.Name, Kind: step.Resource.Kind}
311316
expectedSource, ok := expectedStepSources[key]
312317
require.True(t, ok, "didn't find %v", key)
@@ -325,7 +330,7 @@ EXPECTED:
325330
t.Fatalf("expected step %s not found in %#v", key, fetchedInstallPlan.Status.Plan)
326331
}
327332

328-
t.Logf("All expected resources resolved")
333+
log("All expected resources resolved")
329334

330335
// Verify that the dependent subscription is in a good state
331336
dependentSubscription, err := fetchSubscription(t, crc, testNamespace, strings.Join([]string{dependentPackageStable, dependentCatalogName, testNamespace}, "-"), subscriptionHasInstallPlanChecker)

test/e2e/operator_groups_e2e_test.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func TestOperatorGroup(t *testing.T) {
8080
// Verify copied CVS is deleted
8181
defer cleaner.NotifyTestComplete(t, true)
8282

83+
log := func(s string) {
84+
t.Logf("%s: %s", time.Now().Format("15:04:05.9999"), s)
85+
}
86+
8387
c := newKubeClient(t)
8488
crc := newCRClient(t)
8589
csvName := genName("another-csv-") // must be lowercase for DNS-1123 validation
@@ -114,14 +118,14 @@ func TestOperatorGroup(t *testing.T) {
114118
require.NoError(t, err)
115119
}()
116120

117-
t.Log("Creating CRD")
121+
log("Creating CRD")
118122
mainCRDPlural := genName("opgroup")
119123
mainCRD := newCRD(mainCRDPlural)
120124
cleanupCRD, err := createCRD(c, mainCRD)
121125
require.NoError(t, err)
122126
defer cleanupCRD()
123127

124-
t.Log("Creating operator group")
128+
log("Creating operator group")
125129
operatorGroup := v1.OperatorGroup{
126130
ObjectMeta: metav1.ObjectMeta{
127131
Name: genName("e2e-operator-group-"),
@@ -144,7 +148,7 @@ func TestOperatorGroup(t *testing.T) {
144148
Namespaces: []string{opGroupNamespace, createdOtherNamespace.GetName()},
145149
}
146150

147-
t.Log("Waiting on operator group to have correct status")
151+
log("Waiting on operator group to have correct status")
148152
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
149153
fetched, fetchErr := crc.OperatorsV1().OperatorGroups(opGroupNamespace).Get(operatorGroup.Name, metav1.GetOptions{})
150154
if fetchErr != nil {
@@ -158,7 +162,7 @@ func TestOperatorGroup(t *testing.T) {
158162
})
159163
require.NoError(t, err)
160164

161-
t.Log("Creating CSV")
165+
log("Creating CSV")
162166
// Generate permissions
163167
serviceAccountName := genName("nginx-sa")
164168
permissions := []install.StrategyDeploymentPermissions{
@@ -219,25 +223,25 @@ func TestOperatorGroup(t *testing.T) {
219223
createdCSV, err := crc.OperatorsV1alpha1().ClusterServiceVersions(opGroupNamespace).Create(&aCSV)
220224
require.NoError(t, err)
221225

222-
t.Log("wait for CSV to succeed")
226+
log("wait for CSV to succeed")
223227
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
224228
fetched, err := crc.OperatorsV1alpha1().ClusterServiceVersions(opGroupNamespace).Get(createdCSV.GetName(), metav1.GetOptions{})
225229
if err != nil {
226230
return false, err
227231
}
228-
t.Logf("%s (%s): %s", fetched.Status.Phase, fetched.Status.Reason, fetched.Status.Message)
232+
log(fmt.Sprintf("%s (%s): %s", fetched.Status.Phase, fetched.Status.Reason, fetched.Status.Message))
229233
return csvSucceededChecker(fetched), nil
230234
})
231235
require.NoError(t, err)
232236

233-
t.Log("Waiting for operator namespace csv to have annotations")
237+
log("Waiting for operator namespace csv to have annotations")
234238
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
235239
fetchedCSV, fetchErr := crc.OperatorsV1alpha1().ClusterServiceVersions(opGroupNamespace).Get(csvName, metav1.GetOptions{})
236240
if fetchErr != nil {
237241
if errors.IsNotFound(fetchErr) {
238242
return false, nil
239243
}
240-
t.Logf("Error (in %v): %v", testNamespace, fetchErr.Error())
244+
log(fmt.Sprintf("Error (in %v): %v", testNamespace, fetchErr.Error()))
241245
return false, fetchErr
242246
}
243247
if checkOperatorGroupAnnotations(fetchedCSV, &operatorGroup, true, bothNamespaceNames) == nil {
@@ -247,14 +251,14 @@ func TestOperatorGroup(t *testing.T) {
247251
})
248252
require.NoError(t, err)
249253

250-
t.Log("Waiting for target namespace csv to have annotations (but not target namespaces)")
254+
log("Waiting for target namespace csv to have annotations (but not target namespaces)")
251255
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
252256
fetchedCSV, fetchErr := crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Get(csvName, metav1.GetOptions{})
253257
if fetchErr != nil {
254258
if errors.IsNotFound(fetchErr) {
255259
return false, nil
256260
}
257-
t.Logf("Error (in %v): %v", otherNamespaceName, fetchErr.Error())
261+
log(fmt.Sprintf("Error (in %v): %v", otherNamespaceName, fetchErr.Error()))
258262
return false, fetchErr
259263
}
260264
if checkOperatorGroupAnnotations(fetchedCSV, &operatorGroup, false, "") == nil {
@@ -264,7 +268,7 @@ func TestOperatorGroup(t *testing.T) {
264268
return false, nil
265269
})
266270

267-
t.Log("Checking status on csv in target namespace")
271+
log("Checking status on csv in target namespace")
268272
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
269273
fetchedCSV, fetchErr := crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Get(csvName, metav1.GetOptions{})
270274
if fetchErr != nil {
@@ -281,7 +285,7 @@ func TestOperatorGroup(t *testing.T) {
281285
})
282286
require.NoError(t, err)
283287

284-
t.Log("Waiting on deployment to have correct annotations")
288+
log("Waiting on deployment to have correct annotations")
285289
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
286290
createdDeployment, err := c.GetDeployment(opGroupNamespace, deploymentName)
287291
if err != nil {
@@ -325,7 +329,7 @@ func TestOperatorGroup(t *testing.T) {
325329

326330
ruleChecker := install.NewCSVRuleChecker(roleInformer.Lister(), roleBindingInformer.Lister(), clusterRoleInformer.Lister(), clusterRoleBindingInformer.Lister(), &aCSV)
327331

328-
t.Log("Waiting for operator to have rbac in target namespace")
332+
log("Waiting for operator to have rbac in target namespace")
329333
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
330334
for _, perm := range permissions {
331335
sa, err := c.GetServiceAccount(opGroupNamespace, perm.ServiceAccountName)
@@ -368,7 +372,7 @@ func TestOperatorGroup(t *testing.T) {
368372
require.Equal(t, viewPolicyRules, viewRole.Rules)
369373

370374
// Unsupport all InstallModes
371-
t.Log("unsupporting all csv installmodes")
375+
log("unsupporting all csv installmodes")
372376
fetchedCSV, err := crc.OperatorsV1alpha1().ClusterServiceVersions(opGroupNamespace).Get(csvName, metav1.GetOptions{})
373377
require.NoError(t, err, "could not fetch csv")
374378
fetchedCSV.Spec.InstallModes = []v1alpha1.InstallMode{}
@@ -380,11 +384,11 @@ func TestOperatorGroup(t *testing.T) {
380384
require.NoError(t, err, "csv did not transition to failed as expected")
381385

382386
// ensure deletion cleans up copied CSV
383-
t.Log("deleting parent csv")
387+
log("deleting parent csv")
384388
err = crc.OperatorsV1alpha1().ClusterServiceVersions(opGroupNamespace).Delete(csvName, &metav1.DeleteOptions{})
385389
require.NoError(t, err)
386390

387-
t.Log("waiting for orphaned csv to be deleted")
391+
log("waiting for orphaned csv to be deleted")
388392
err = waitForDelete(func() error {
389393
_, err = crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Get(csvName, metav1.GetOptions{})
390394
return err

test/e2e/subscription_e2e_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77
"sync"
88
"testing"
9+
"time"
910

1011
"github.com/blang/semver"
1112
"github.com/ghodss/yaml"
@@ -329,17 +330,21 @@ func fetchSubscription(t *testing.T, crc versioned.Interface, namespace, name st
329330
var fetchedSubscription *v1alpha1.Subscription
330331
var err error
331332

333+
log := func(s string) {
334+
t.Logf("%s: %s", time.Now().Format("15:04:05.9999"), s)
335+
}
336+
332337
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
333338
fetchedSubscription, err = crc.OperatorsV1alpha1().Subscriptions(namespace).Get(name, metav1.GetOptions{})
334339
if err != nil || fetchedSubscription == nil {
335340
return false, err
336341
}
337-
t.Logf("%s (%s): %s", fetchedSubscription.Status.State, fetchedSubscription.Status.CurrentCSV, fetchedSubscription.Status.Install)
342+
log(fmt.Sprintf("%s (%s): %s", fetchedSubscription.Status.State, fetchedSubscription.Status.CurrentCSV, fetchedSubscription.Status.InstallPlanRef))
338343
return checker(fetchedSubscription), nil
339344
})
340345
if err != nil {
341-
t.Logf("never got correct status: %#v", fetchedSubscription.Status)
342-
t.Logf("subscription spec: %#v", fetchedSubscription.Spec)
346+
log(fmt.Sprintf("never got correct status: %#v", fetchedSubscription.Status))
347+
log(fmt.Sprintf("subscription spec: %#v", fetchedSubscription.Spec))
343348
}
344349
return fetchedSubscription, err
345350
}

test/e2e/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939

4040
const (
4141
pollInterval = 1 * time.Second
42-
pollDuration = 3 * time.Minute
42+
pollDuration = 5 * time.Minute
4343

4444
olmConfigMap = "olm-operators"
4545
// sync name with scripts/install_local.sh

0 commit comments

Comments
 (0)