knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/test/upgrade/steps.go (about) 1 /* 2 Copyright 2020 The Knative Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package upgrade 18 19 import ( 20 "testing" 21 ) 22 23 const skippingOperationTemplate = `Skipping "%s" as previous operation have failed` 24 25 func (se *suiteExecution) installingBase(t *testing.T, num int) { 26 se.processOperationGroup(t, operationGroup{ 27 num: num, 28 operations: se.suite.installations.Base, 29 groupName: "InstallingBase", 30 elementTemplate: `%d.%d) Installing base install of "%s".`, 31 skippingGroupTemplate: "%d) 💿 No base installation registered. Skipping.", 32 groupTemplate: "%d) 💿 Installing base installations. %d are registered.", 33 }) 34 } 35 36 func (se *suiteExecution) preUpgradeTests(t *testing.T, num int) { 37 se.processOperationGroup(t, operationGroup{ 38 num: num, 39 operations: se.suite.tests.preUpgrade, 40 groupName: "PreUpgradeTests", 41 elementTemplate: `%d.%d) Testing with "%s".`, 42 skippingGroupTemplate: "%d) ✅️️ No pre upgrade tests registered. Skipping.", 43 groupTemplate: "%d) ✅️️ Testing functionality before upgrade is performed." + 44 " %d tests are registered.", 45 }) 46 } 47 48 func (se *suiteExecution) runContinualTests(t *testing.T, num int, stopCh <-chan struct{}) { 49 l := se.configuration.logger(t) 50 operations := se.suite.tests.continual 51 groupTemplate := "%d) 🔄 Starting continual tests. " + 52 "%d tests are registered." 53 elementTemplate := `%d.%d) Starting continual tests of "%s".` 54 numOps := len(operations) 55 if numOps > 0 { 56 l.Infof(groupTemplate, num, numOps) 57 for i := range operations { 58 operation := operations[i] 59 l.Debugf(elementTemplate, num, i+1, operation.Name()) 60 t.Run(operation.Name(), func(t *testing.T) { 61 l := se.configuration.logger(t) 62 setup := operation.Setup() 63 setup(Context{T: t, Log: l}) 64 if t.Failed() { 65 return 66 } 67 t.Parallel() 68 handle := operation.Handler() 69 // Blocking operation. 70 handle(BackgroundContext{ 71 T: t, 72 Log: l, 73 Stop: stopCh, 74 }) 75 l.Debugf(`Finished "%s"`, operation.Name()) 76 }) 77 } 78 } else { 79 l.Infof("%d) 🔄 No continual tests registered. Skipping.", num) 80 } 81 } 82 83 func (se *suiteExecution) upgradeWith(t *testing.T, num int) { 84 se.processOperationGroup(t, operationGroup{ 85 num: num, 86 operations: se.suite.installations.UpgradeWith, 87 groupName: "UpgradeWith", 88 elementTemplate: `%d.%d) Upgrading with "%s".`, 89 skippingGroupTemplate: "%d) 📀 No upgrade operations registered. Skipping.", 90 groupTemplate: "%d) 📀 Upgrading with %d registered operations.", 91 }) 92 } 93 94 func (se *suiteExecution) postUpgradeTests(t *testing.T, num int) { 95 se.processOperationGroup(t, operationGroup{ 96 num: num, 97 operations: se.suite.tests.postUpgrade, 98 groupName: "PostUpgradeTests", 99 elementTemplate: `%d.%d) Testing with "%s".`, 100 skippingGroupTemplate: "%d) ✅️️ No post upgrade tests registered. Skipping.", 101 groupTemplate: "%d) ✅️️ Testing functionality after upgrade is performed." + 102 " %d tests are registered.", 103 }) 104 } 105 106 func (se *suiteExecution) downgradeWith(t *testing.T, num int) { 107 se.processOperationGroup(t, operationGroup{ 108 num: num, 109 operations: se.suite.installations.DowngradeWith, 110 groupName: "DowngradeWith", 111 elementTemplate: `%d.%d) Downgrading with "%s".`, 112 skippingGroupTemplate: "%d) 💿 No downgrade operations registered. Skipping.", 113 groupTemplate: "%d) 💿 Downgrading with %d registered operations.", 114 }) 115 } 116 117 func (se *suiteExecution) postDowngradeTests(t *testing.T, num int) { 118 se.processOperationGroup(t, operationGroup{ 119 num: num, 120 operations: se.suite.tests.postDowngrade, 121 groupName: "PostDowngradeTests", 122 elementTemplate: `%d.%d) Testing with "%s".`, 123 skippingGroupTemplate: "%d) ✅️️ No post downgrade tests registered. Skipping.", 124 groupTemplate: "%d) ✅️️ Testing functionality after downgrade is performed." + 125 " %d tests are registered.", 126 }) 127 }