upgrade.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Package upgrades provides a framework for testing Kubernetes
  14. // features before, during, and after different types of upgrades.
  15. package upgrades
  16. import (
  17. "k8s.io/apimachinery/pkg/util/version"
  18. "k8s.io/kubernetes/test/e2e/framework"
  19. )
  20. // UpgradeType represents different types of upgrades.
  21. type UpgradeType int
  22. const (
  23. // MasterUpgrade indicates that only the master is being upgraded.
  24. MasterUpgrade UpgradeType = iota
  25. // NodeUpgrade indicates that only the nodes are being upgraded.
  26. NodeUpgrade
  27. // ClusterUpgrade indicates that both master and nodes are
  28. // being upgraded.
  29. ClusterUpgrade
  30. // EtcdUpgrade indicates that only etcd is being upgraded (or migrated
  31. // between storage versions).
  32. EtcdUpgrade
  33. )
  34. // Test is an interface for upgrade tests.
  35. type Test interface {
  36. // Name should return a test name sans spaces.
  37. Name() string
  38. // Setup should create and verify whatever objects need to
  39. // exist before the upgrade disruption starts.
  40. Setup(f *framework.Framework)
  41. // Test will run during the upgrade. When the upgrade is
  42. // complete, done will be closed and final validation can
  43. // begin.
  44. Test(f *framework.Framework, done <-chan struct{}, upgrade UpgradeType)
  45. // Teardown should clean up any objects that are created that
  46. // aren't already cleaned up by the framework. This will
  47. // always be called, even if Setup failed.
  48. Teardown(f *framework.Framework)
  49. }
  50. // Skippable is an interface that an upgrade test can implement to be
  51. // able to indicate that it should be skipped.
  52. type Skippable interface {
  53. // Skip should return true if test should be skipped. upgCtx
  54. // provides information about the upgrade that is going to
  55. // occur.
  56. Skip(upgCtx UpgradeContext) bool
  57. }
  58. // UpgradeContext contains information about all the stages of the
  59. // upgrade that is going to occur.
  60. type UpgradeContext struct {
  61. Versions []VersionContext
  62. }
  63. // VersionContext represents a stage of the upgrade.
  64. type VersionContext struct {
  65. Version version.Version
  66. NodeImage string
  67. }