diff --git a/test/e2e/cloud/gcp/apps/framework.go b/test/e2e/cloud/gcp/apps/framework.go new file mode 100644 index 00000000000..46dccce48fc --- /dev/null +++ b/test/e2e/cloud/gcp/apps/framework.go @@ -0,0 +1,24 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apps + +import "github.com/onsi/ginkgo" + +// SIGDescribe annotates the test with the SIG label. +func SIGDescribe(text string, body func()) bool { + return ginkgo.Describe("[sig-apps] "+text, body) +} diff --git a/test/e2e/cloud/gcp/apps/stateful_apps.go b/test/e2e/cloud/gcp/apps/stateful_apps.go new file mode 100644 index 00000000000..e131cf2c321 --- /dev/null +++ b/test/e2e/cloud/gcp/apps/stateful_apps.go @@ -0,0 +1,51 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apps + +import ( + "k8s.io/kubernetes/test/e2e/cloud/gcp/common" + "k8s.io/kubernetes/test/e2e/framework" + "k8s.io/kubernetes/test/e2e/upgrades" + "k8s.io/kubernetes/test/e2e/upgrades/apps" + "k8s.io/kubernetes/test/utils/junit" + + "github.com/onsi/ginkgo" +) + +var upgradeTests = []upgrades.Test{ + &apps.MySQLUpgradeTest{}, + &apps.EtcdUpgradeTest{}, + &apps.CassandraUpgradeTest{}, +} + +var _ = SIGDescribe("stateful Upgrade [Feature:StatefulUpgrade]", func() { + f := framework.NewDefaultFramework("stateful-upgrade") + + ginkgo.Describe("stateful upgrade", func() { + ginkgo.It("should maintain a functioning cluster", func() { + upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) + framework.ExpectNoError(err) + + testSuite := &junit.TestSuite{Name: "Stateful upgrade"} + statefulUpgradeTest := &junit.TestCase{Name: "[sig-apps] stateful-upgrade", Classname: "upgrade_tests"} + testSuite.TestCases = append(testSuite.TestCases, statefulUpgradeTest) + + upgradeFunc := common.ClusterUpgradeFunc(f, upgCtx, statefulUpgradeTest, nil, nil) + upgrades.RunUpgradeSuite(upgCtx, upgradeTests, testSuite, upgrades.ClusterUpgrade, upgradeFunc) + }) + }) +}) diff --git a/test/e2e/cloud/gcp/auth/framework.go b/test/e2e/cloud/gcp/auth/framework.go new file mode 100644 index 00000000000..27880f2d786 --- /dev/null +++ b/test/e2e/cloud/gcp/auth/framework.go @@ -0,0 +1,24 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package auth + +import "github.com/onsi/ginkgo" + +// SIGDescribe annotates the test with the SIG label. +func SIGDescribe(text string, body func()) bool { + return ginkgo.Describe("[sig-auth] "+text, body) +} diff --git a/test/e2e/cloud/gcp/auth/service_account_admission_controller_migration.go b/test/e2e/cloud/gcp/auth/service_account_admission_controller_migration.go new file mode 100644 index 00000000000..44384c9a591 --- /dev/null +++ b/test/e2e/cloud/gcp/auth/service_account_admission_controller_migration.go @@ -0,0 +1,53 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package auth + +import ( + "k8s.io/kubernetes/test/e2e/cloud/gcp/common" + "k8s.io/kubernetes/test/e2e/framework" + "k8s.io/kubernetes/test/e2e/upgrades" + "k8s.io/kubernetes/test/e2e/upgrades/auth" + "k8s.io/kubernetes/test/utils/junit" + + "github.com/onsi/ginkgo" +) + +var upgradeTests = []upgrades.Test{ + &auth.ServiceAccountAdmissionControllerMigrationTest{}, +} + +var _ = SIGDescribe("ServiceAccount admission controller migration [Feature:BoundServiceAccountTokenVolume]", func() { + f := framework.NewDefaultFramework("serviceaccount-admission-controller-migration") + + ginkgo.Describe("master upgrade", func() { + ginkgo.It("should maintain a functioning cluster", func() { + upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) + framework.ExpectNoError(err) + + testSuite := &junit.TestSuite{Name: "ServiceAccount admission controller migration"} + serviceaccountAdmissionControllerMigrationTest := &junit.TestCase{ + Name: "[sig-auth] serviceaccount-admission-controller-migration", + Classname: "upgrade_tests", + } + testSuite.TestCases = append(testSuite.TestCases, serviceaccountAdmissionControllerMigrationTest) + + extraEnvs := []string{"KUBE_FEATURE_GATES=BoundServiceAccountTokenVolume=true"} + upgradeFunc := common.ControlPlaneUpgradeFunc(f, upgCtx, serviceaccountAdmissionControllerMigrationTest, extraEnvs) + upgrades.RunUpgradeSuite(upgCtx, upgradeTests, testSuite, upgrades.MasterUpgrade, upgradeFunc) + }) + }) +}) diff --git a/test/e2e/cloud/gcp/cluster_upgrade.go b/test/e2e/cloud/gcp/cluster_upgrade.go index b78bf8ada9c..b8361b11b6e 100644 --- a/test/e2e/cloud/gcp/cluster_upgrade.go +++ b/test/e2e/cloud/gcp/cluster_upgrade.go @@ -17,14 +17,10 @@ limitations under the License. package gcp import ( - "fmt" - "k8s.io/kubernetes/test/e2e/cloud/gcp/common" "k8s.io/kubernetes/test/e2e/framework" - e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper" "k8s.io/kubernetes/test/e2e/upgrades" "k8s.io/kubernetes/test/e2e/upgrades/apps" - "k8s.io/kubernetes/test/e2e/upgrades/auth" "k8s.io/kubernetes/test/e2e/upgrades/autoscaling" "k8s.io/kubernetes/test/e2e/upgrades/network" "k8s.io/kubernetes/test/e2e/upgrades/node" @@ -34,47 +30,25 @@ import ( "github.com/onsi/ginkgo" ) +// TODO: Those tests should be splitted by SIG and moved to SIG-owned directories, +// however that involves also splitting the actual upgrade jobs too. +// Figure out the eventual solution for it. var upgradeTests = []upgrades.Test{ - &network.ServiceUpgradeTest{}, - &node.SecretUpgradeTest{}, - &apps.ReplicaSetUpgradeTest{}, - &apps.StatefulSetUpgradeTest{}, + &apps.DaemonSetUpgradeTest{}, &apps.DeploymentUpgradeTest{}, &apps.JobUpgradeTest{}, - &node.ConfigMapUpgradeTest{}, + &apps.ReplicaSetUpgradeTest{}, + &apps.StatefulSetUpgradeTest{}, &autoscaling.HPAUpgradeTest{}, - &storage.PersistentVolumeUpgradeTest{}, - &apps.DaemonSetUpgradeTest{}, + &network.ServiceUpgradeTest{}, &node.AppArmorUpgradeTest{}, + &node.ConfigMapUpgradeTest{}, + &node.SecretUpgradeTest{}, + &storage.PersistentVolumeUpgradeTest{}, &storage.VolumeModeDowngradeTest{}, } -var statefulsetUpgradeTests = []upgrades.Test{ - &apps.MySQLUpgradeTest{}, - &apps.EtcdUpgradeTest{}, - &apps.CassandraUpgradeTest{}, -} - -var kubeProxyUpgradeTests = []upgrades.Test{ - &network.KubeProxyUpgradeTest{}, - &network.ServiceUpgradeTest{}, -} - -var kubeProxyDowngradeTests = []upgrades.Test{ - &network.KubeProxyDowngradeTest{}, - &network.ServiceUpgradeTest{}, -} - -var serviceaccountAdmissionControllerMigrationTests = []upgrades.Test{ - &auth.ServiceAccountAdmissionControllerMigrationTest{}, -} - -func kubeProxyDaemonSetExtraEnvs(enableKubeProxyDaemonSet bool) []string { - return []string{fmt.Sprintf("KUBE_PROXY_DAEMONSET=%v", enableKubeProxyDaemonSet)} -} - -// TODO(#98326): Split the test by SIGs, move to appropriate directories and use SIGDescribe. -var _ = ginkgo.Describe("Upgrade [Feature:Upgrade]", func() { +var _ = SIGDescribe("Upgrade [Feature:Upgrade]", func() { f := framework.NewDefaultFramework("cluster-upgrade") // Create the frameworks here because we can only create them @@ -111,8 +85,7 @@ var _ = ginkgo.Describe("Upgrade [Feature:Upgrade]", func() { }) }) -// TODO(#98326): Split the test by SIGs, move to appropriate directories and use SIGDescribe. -var _ = ginkgo.Describe("Downgrade [Feature:Downgrade]", func() { +var _ = SIGDescribe("Downgrade [Feature:Downgrade]", func() { f := framework.NewDefaultFramework("cluster-downgrade") ginkgo.Describe("cluster downgrade", func() { @@ -129,90 +102,3 @@ var _ = ginkgo.Describe("Downgrade [Feature:Downgrade]", func() { }) }) }) - -// TODO(#98326): Move the test to sig-aps dir and use SIGDescribe. -var _ = ginkgo.Describe("[sig-apps] stateful Upgrade [Feature:StatefulUpgrade]", func() { - f := framework.NewDefaultFramework("stateful-upgrade") - - ginkgo.Describe("stateful upgrade", func() { - ginkgo.It("should maintain a functioning cluster", func() { - upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) - framework.ExpectNoError(err) - - testSuite := &junit.TestSuite{Name: "Stateful upgrade"} - statefulUpgradeTest := &junit.TestCase{Name: "[sig-apps] stateful-upgrade", Classname: "upgrade_tests"} - testSuite.TestCases = append(testSuite.TestCases, statefulUpgradeTest) - - upgradeFunc := common.ClusterUpgradeFunc(f, upgCtx, statefulUpgradeTest, nil, nil) - upgrades.RunUpgradeSuite(upgCtx, statefulsetUpgradeTests, testSuite, upgrades.ClusterUpgrade, upgradeFunc) - }) - }) -}) - -// TODO(#98326): Move the test to sig-network dir and use SIGDescribe. -var _ = ginkgo.Describe("kube-proxy migration [Feature:KubeProxyDaemonSetMigration]", func() { - f := framework.NewDefaultFramework("kube-proxy-ds-migration") - - ginkgo.BeforeEach(func() { - e2eskipper.SkipUnlessProviderIs("gce") - }) - - ginkgo.Describe("Upgrade kube-proxy from static pods to a DaemonSet", func() { - ginkgo.It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetUpgrade]", func() { - upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) - framework.ExpectNoError(err) - - testSuite := &junit.TestSuite{Name: "kube-proxy upgrade"} - kubeProxyUpgradeTest := &junit.TestCase{ - Name: "kube-proxy-ds-upgrade", - Classname: "upgrade_tests", - } - testSuite.TestCases = append(testSuite.TestCases, kubeProxyUpgradeTest) - - extraEnvs := kubeProxyDaemonSetExtraEnvs(true) - upgradeFunc := common.ClusterUpgradeFunc(f, upgCtx, kubeProxyUpgradeTest, extraEnvs, extraEnvs) - upgrades.RunUpgradeSuite(upgCtx, kubeProxyUpgradeTests, testSuite, upgrades.ClusterUpgrade, upgradeFunc) - }) - }) - - ginkgo.Describe("Downgrade kube-proxy from a DaemonSet to static pods", func() { - ginkgo.It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetDowngrade]", func() { - upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) - framework.ExpectNoError(err) - - testSuite := &junit.TestSuite{Name: "kube-proxy downgrade"} - kubeProxyDowngradeTest := &junit.TestCase{ - Name: "kube-proxy-ds-downgrade", - Classname: "upgrade_tests", - } - testSuite.TestCases = append(testSuite.TestCases, kubeProxyDowngradeTest) - - extraEnvs := kubeProxyDaemonSetExtraEnvs(false) - upgradeFunc := common.ClusterDowngradeFunc(f, upgCtx, kubeProxyDowngradeTest, extraEnvs, extraEnvs) - upgrades.RunUpgradeSuite(upgCtx, kubeProxyDowngradeTests, testSuite, upgrades.ClusterUpgrade, upgradeFunc) - }) - }) -}) - -// TODO(#98326): Move the test to sig-auth dir and use SIGDescribe. -var _ = ginkgo.Describe("[sig-auth] ServiceAccount admission controller migration [Feature:BoundServiceAccountTokenVolume]", func() { - f := framework.NewDefaultFramework("serviceaccount-admission-controller-migration") - - ginkgo.Describe("master upgrade", func() { - ginkgo.It("should maintain a functioning cluster", func() { - upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) - framework.ExpectNoError(err) - - testSuite := &junit.TestSuite{Name: "ServiceAccount admission controller migration"} - serviceaccountAdmissionControllerMigrationTest := &junit.TestCase{ - Name: "[sig-auth] serviceaccount-admission-controller-migration", - Classname: "upgrade_tests", - } - testSuite.TestCases = append(testSuite.TestCases, serviceaccountAdmissionControllerMigrationTest) - - extraEnvs := []string{"KUBE_FEATURE_GATES=BoundServiceAccountTokenVolume=true"} - upgradeFunc := common.ControlPlaneUpgradeFunc(f, upgCtx, serviceaccountAdmissionControllerMigrationTest, extraEnvs) - upgrades.RunUpgradeSuite(upgCtx, serviceaccountAdmissionControllerMigrationTests, testSuite, upgrades.MasterUpgrade, upgradeFunc) - }) - }) -}) diff --git a/test/e2e/cloud/gcp/imports.go b/test/e2e/cloud/gcp/imports.go index fb35d820dc0..ca2070bd4ff 100644 --- a/test/e2e/cloud/gcp/imports.go +++ b/test/e2e/cloud/gcp/imports.go @@ -18,5 +18,8 @@ package gcp import ( // ensure these packages are scanned by ginkgo for e2e tests + _ "k8s.io/kubernetes/test/e2e/cloud/gcp/apps" + _ "k8s.io/kubernetes/test/e2e/cloud/gcp/auth" + _ "k8s.io/kubernetes/test/e2e/cloud/gcp/network" _ "k8s.io/kubernetes/test/e2e/cloud/gcp/node" ) diff --git a/test/e2e/cloud/gcp/network/framework.go b/test/e2e/cloud/gcp/network/framework.go new file mode 100644 index 00000000000..2a197e9e02a --- /dev/null +++ b/test/e2e/cloud/gcp/network/framework.go @@ -0,0 +1,24 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package network + +import "github.com/onsi/ginkgo" + +// SIGDescribe annotates the test with the SIG label. +func SIGDescribe(text string, body func()) bool { + return ginkgo.Describe("[sig-network] "+text, body) +} diff --git a/test/e2e/cloud/gcp/network/kube_proxy_migration.go b/test/e2e/cloud/gcp/network/kube_proxy_migration.go new file mode 100644 index 00000000000..0fab8ce50b1 --- /dev/null +++ b/test/e2e/cloud/gcp/network/kube_proxy_migration.go @@ -0,0 +1,88 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package network + +import ( + "fmt" + + "k8s.io/kubernetes/test/e2e/cloud/gcp/common" + "k8s.io/kubernetes/test/e2e/framework" + e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper" + "k8s.io/kubernetes/test/e2e/upgrades" + "k8s.io/kubernetes/test/e2e/upgrades/network" + "k8s.io/kubernetes/test/utils/junit" + + "github.com/onsi/ginkgo" +) + +var upgradeTests = []upgrades.Test{ + &network.KubeProxyUpgradeTest{}, + &network.ServiceUpgradeTest{}, +} + +var downgradeTests = []upgrades.Test{ + &network.KubeProxyDowngradeTest{}, + &network.ServiceUpgradeTest{}, +} + +func kubeProxyDaemonSetExtraEnvs(enableKubeProxyDaemonSet bool) []string { + return []string{fmt.Sprintf("KUBE_PROXY_DAEMONSET=%v", enableKubeProxyDaemonSet)} +} + +var _ = SIGDescribe("kube-proxy migration [Feature:KubeProxyDaemonSetMigration]", func() { + f := framework.NewDefaultFramework("kube-proxy-ds-migration") + + ginkgo.BeforeEach(func() { + e2eskipper.SkipUnlessProviderIs("gce") + }) + + ginkgo.Describe("Upgrade kube-proxy from static pods to a DaemonSet", func() { + ginkgo.It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetUpgrade]", func() { + upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) + framework.ExpectNoError(err) + + testSuite := &junit.TestSuite{Name: "kube-proxy upgrade"} + kubeProxyUpgradeTest := &junit.TestCase{ + Name: "kube-proxy-ds-upgrade", + Classname: "upgrade_tests", + } + testSuite.TestCases = append(testSuite.TestCases, kubeProxyUpgradeTest) + + extraEnvs := kubeProxyDaemonSetExtraEnvs(true) + upgradeFunc := common.ClusterUpgradeFunc(f, upgCtx, kubeProxyUpgradeTest, extraEnvs, extraEnvs) + upgrades.RunUpgradeSuite(upgCtx, upgradeTests, testSuite, upgrades.ClusterUpgrade, upgradeFunc) + }) + }) + + ginkgo.Describe("Downgrade kube-proxy from a DaemonSet to static pods", func() { + ginkgo.It("should maintain a functioning cluster [Feature:KubeProxyDaemonSetDowngrade]", func() { + upgCtx, err := common.GetUpgradeContext(f.ClientSet.Discovery()) + framework.ExpectNoError(err) + + testSuite := &junit.TestSuite{Name: "kube-proxy downgrade"} + kubeProxyDowngradeTest := &junit.TestCase{ + Name: "kube-proxy-ds-downgrade", + Classname: "upgrade_tests", + } + testSuite.TestCases = append(testSuite.TestCases, kubeProxyDowngradeTest) + + extraEnvs := kubeProxyDaemonSetExtraEnvs(false) + upgradeFunc := common.ClusterDowngradeFunc(f, upgCtx, kubeProxyDowngradeTest, extraEnvs, extraEnvs) + upgrades.RunUpgradeSuite(upgCtx, downgradeTests, testSuite, upgrades.ClusterUpgrade, upgradeFunc) + }) + }) +})