@@ -50,18 +50,34 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
50
50
newIIB := os .Getenv ("CAMEL_K_NEW_IIB" )
51
51
kamel := os .Getenv ("RELEASED_KAMEL_BIN" )
52
52
53
+ // optional options
54
+ prevUpdateChannel := os .Getenv ("CAMEL_K_PREV_UPGRADE_CHANNEL" )
55
+ newUpdateChannel := os .Getenv ("CAMEL_K_NEW_UPGRADE_CHANNEL" )
56
+
53
57
if prevIIB == "" || newIIB == "" {
54
58
t .Skip ("OLM Upgrade test requires the CAMEL_K_PREV_IIB and CAMEL_K_NEW_IIB environment variables" )
55
59
}
56
60
61
+ crossChannelUpgrade := false
62
+ if prevUpdateChannel != "" && newUpdateChannel != "" && prevUpdateChannel != newUpdateChannel {
63
+ crossChannelUpgrade = true
64
+ t .Logf ("Testing cross-OLM channel upgrade %s -> %s" , prevUpdateChannel , newUpdateChannel )
65
+ }
66
+
57
67
WithNewTestNamespace (t , func (ns string ) {
58
68
Expect (createOrUpdateCatalogSource (ns , catalogSourceName , prevIIB )).To (Succeed ())
59
69
Eventually (catalogSourcePhase (ns , catalogSourceName ), TestTimeoutMedium ).Should (Equal ("READY" ))
60
70
61
71
// Set KAMEL_BIN only for this test - don't override the ENV variable for all tests
62
72
Expect (os .Setenv ("KAMEL_BIN" , kamel )).To (Succeed ())
63
73
64
- Expect (Kamel ("install" , "-n" , ns , "--olm=true" , "--olm-source" , catalogSourceName , "--olm-source-namespace" , ns ).Execute ()).To (Succeed ())
74
+ args := []string {"install" , "-n" , ns , "--olm=true" , "--olm-source" , catalogSourceName , "--olm-source-namespace" , ns }
75
+
76
+ if crossChannelUpgrade {
77
+ args = append (args , "--olm-channel" , os .Getenv ("CAMEL_K_PREV_UPGRADE_CHANNEL" ))
78
+ }
79
+
80
+ Expect (Kamel (args ... ).Execute ()).To (Succeed ())
65
81
66
82
// Find the only one Camel-K CSV
67
83
noAdditionalConditions := func (csv olm.ClusterServiceVersion ) bool {
@@ -102,6 +118,14 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
102
118
// Trigger Camel K operator upgrade by updating the CatalogSource with the new index image
103
119
Expect (createOrUpdateCatalogSource (ns , catalogSourceName , newIIB )).To (Succeed ())
104
120
121
+ if crossChannelUpgrade {
122
+ t .Log ("Updating Camel-K subscription OLM update channel." )
123
+ s := ckSubscription (ns )()
124
+ ctrlutil .CreateOrUpdate (TestContext , TestClient (), s , func () error {
125
+ s .Spec .Channel = newUpdateChannel
126
+ return nil
127
+ })
128
+ }
105
129
// Check the previous CSV is being replaced
106
130
Eventually (clusterServiceVersionPhase (func (csv olm.ClusterServiceVersion ) bool {
107
131
return csv .Spec .Version .Version .String () == prevCSVVersion .Version .String ()
0 commit comments