1 /* 2 Copyright 2017 The Kubernetes 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 upgrades provides a framework for testing Kubernetes 18 // features before, during, and after different types of upgrades. 19 package upgrades 20 21 import ( 22 "context" 23 24 "k8s.io/apimachinery/pkg/util/version" 25 "k8s.io/kubernetes/test/e2e/framework" 26 ) 27 28 // UpgradeType represents different types of upgrades. 29 type UpgradeType int 30 31 const ( 32 // MasterUpgrade indicates that only the master is being upgraded. 33 MasterUpgrade UpgradeType = iota 34 35 // NodeUpgrade indicates that only the nodes are being upgraded. 36 NodeUpgrade 37 38 // ClusterUpgrade indicates that both master and nodes are 39 // being upgraded. 40 ClusterUpgrade 41 42 // EtcdUpgrade indicates that only etcd is being upgraded (or migrated 43 // between storage versions). 44 EtcdUpgrade 45 ) 46 47 // Test is an interface for upgrade tests. 48 type Test interface { 49 // Name should return a test name sans spaces. 50 Name() string 51 52 // Setup should create and verify whatever objects need to 53 // exist before the upgrade disruption starts. 54 Setup(ctx context.Context, f *framework.Framework) 55 56 // Test will run during the upgrade. When the upgrade is 57 // complete, done will be closed and final validation can 58 // begin. 59 Test(ctx context.Context, f *framework.Framework, done <-chan struct{}, upgrade UpgradeType) 60 61 // Teardown should clean up any objects that are created that 62 // aren't already cleaned up by the framework. This will 63 // always be called, even if Setup failed. 64 Teardown(ctx context.Context, f *framework.Framework) 65 } 66 67 // Skippable is an interface that an upgrade test can implement to be 68 // able to indicate that it should be skipped. 69 type Skippable interface { 70 // Skip should return true if test should be skipped. upgCtx 71 // provides information about the upgrade that is going to 72 // occur. 73 Skip(upgCtx UpgradeContext) bool 74 } 75 76 // UpgradeContext contains information about all the stages of the 77 // upgrade that is going to occur. 78 type UpgradeContext struct { 79 Versions []VersionContext 80 } 81 82 // VersionContext represents a stage of the upgrade. 83 type VersionContext struct { 84 Version version.Version 85 NodeImage string 86 } 87