knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/test/upgrade/suite_examples_test.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_test 18 19 import ( 20 "time" 21 22 "knative.dev/pkg/test/upgrade" 23 ) 24 25 const ( 26 shortWait = 50 * time.Microsecond 27 longWait = 750 * time.Microsecond 28 ) 29 30 func init() { 31 upgrade.DefaultWaitTime = shortWait 32 } 33 34 var ( 35 notFailing = failurePoint{step: -1, element: -1} 36 messageFormatters = messageFormatterRepository{ 37 baseInstall: createMessages(formats{ 38 starting: "%d) 💿 Installing base installations. %d are registered.", 39 element: `%d.%d) Installing base install of "%s".`, 40 skipped: "%d) 💿 No base installation registered. Skipping.", 41 }), 42 preUpgrade: createMessages(formats{ 43 starting: "%d) ✅️️ Testing functionality before upgrade is performed. %d tests are registered.", 44 element: `%d.%d) Testing with "%s".`, 45 skipped: "%d) ✅️️ No pre upgrade tests registered. Skipping.", 46 }), 47 startContinual: createMessages(formats{ 48 starting: "%d) 🔄 Starting continual tests. %d tests are registered.", 49 element: `%d.%d) Starting continual tests of "%s".`, 50 skipped: "%d) 🔄 No continual tests registered. Skipping.", 51 }), 52 upgrade: createMessages(formats{ 53 starting: "%d) 📀 Upgrading with %d registered operations.", 54 element: `%d.%d) Upgrading with "%s".`, 55 skipped: "%d) 📀 No upgrade operations registered. Skipping.", 56 }), 57 postUpgrade: createMessages(formats{ 58 starting: "%d) ✅️️ Testing functionality after upgrade is performed. %d tests are registered.", 59 element: `%d.%d) Testing with "%s".`, 60 skipped: "%d) ✅️️ No post upgrade tests registered. Skipping.", 61 }), 62 downgrade: createMessages(formats{ 63 starting: "%d) 💿 Downgrading with %d registered operations.", 64 element: `%d.%d) Downgrading with "%s".`, 65 skipped: "%d) 💿 No downgrade operations registered. Skipping.", 66 }), 67 postDowngrade: createMessages(formats{ 68 starting: "%d) ✅️️ Testing functionality after downgrade is performed. %d tests are registered.", 69 element: `%d.%d) Testing with "%s".`, 70 skipped: "%d) ✅️️ No post downgrade tests registered. Skipping.", 71 }), 72 } 73 ) 74 75 func servingComponent() component { 76 return component{ 77 installs: installs{ 78 stable: upgrade.NewOperation("Serving latest stable release", func(c upgrade.Context) { 79 c.Log.Info("Installing Serving stable 0.17.1") 80 time.Sleep(longWait) 81 }), 82 head: upgrade.NewOperation("Serving HEAD", func(c upgrade.Context) { 83 c.Log.Info("Installing Serving HEAD at e3c4563") 84 time.Sleep(longWait) 85 }), 86 }, 87 tests: tests{ 88 preUpgrade: upgrade.NewOperation("Serving pre upgrade test", func(c upgrade.Context) { 89 c.Log.Info("Running Serving pre upgrade test") 90 time.Sleep(shortWait) 91 }), 92 postUpgrade: upgrade.NewOperation("Serving post upgrade test", func(c upgrade.Context) { 93 c.Log.Info("Running Serving post upgrade test") 94 time.Sleep(shortWait) 95 }), 96 postDowngrade: upgrade.NewOperation("Serving post downgrade test", func(c upgrade.Context) { 97 c.Log.Info("Running Serving post downgrade test") 98 time.Sleep(shortWait) 99 }), 100 continual: upgrade.NewBackgroundOperation("Serving continual test", 101 func(c upgrade.Context) { 102 c.Log.Info("Setup of Serving continual test") 103 time.Sleep(shortWait) 104 }, 105 func(bc upgrade.BackgroundContext) { 106 bc.Log.Info("Running Serving continual test") 107 upgrade.WaitForStopEvent(bc, upgrade.WaitForStopEventConfiguration{ 108 Name: "Serving", 109 OnStop: func() { 110 bc.Log.Info("Stopping and verify of Serving continual test") 111 time.Sleep(shortWait) 112 }, 113 OnWait: func(bc upgrade.BackgroundContext, self upgrade.WaitForStopEventConfiguration) { 114 bc.Log.Debugf("%s - probing functionality...", self.Name) 115 }, 116 WaitTime: shortWait, 117 }) 118 }), 119 }, 120 } 121 } 122 123 func eventingComponent() component { 124 return component{ 125 installs: installs{ 126 stable: upgrade.NewOperation("Eventing latest stable release", func(c upgrade.Context) { 127 c.Log.Info("Installing Eventing stable 0.17.2") 128 time.Sleep(longWait) 129 }), 130 head: upgrade.NewOperation("Eventing HEAD", func(c upgrade.Context) { 131 c.Log.Info("Installing Eventing HEAD at 12f67cc") 132 time.Sleep(longWait) 133 }), 134 }, 135 tests: tests{ 136 preUpgrade: upgrade.NewOperation("Eventing pre upgrade test", func(c upgrade.Context) { 137 c.Log.Info("Running Eventing pre upgrade test") 138 time.Sleep(shortWait) 139 }), 140 postUpgrade: upgrade.NewOperation("Eventing post upgrade test", func(c upgrade.Context) { 141 c.Log.Info("Running Eventing post upgrade test") 142 time.Sleep(shortWait) 143 }), 144 postDowngrade: upgrade.NewOperation("Eventing post downgrade test", func(c upgrade.Context) { 145 c.Log.Info("Running Eventing post downgrade test") 146 time.Sleep(shortWait) 147 }), 148 }, 149 } 150 } 151 152 func probeOnWaitFunc() func(upgrade.BackgroundContext, upgrade.WaitForStopEventConfiguration) { 153 return func(bc upgrade.BackgroundContext, self upgrade.WaitForStopEventConfiguration) { 154 bc.Log.Debugf("%s - probing functionality...", self.Name) 155 } 156 }