-
Notifications
You must be signed in to change notification settings - Fork 67
/
test.go
126 lines (108 loc) · 6.46 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
//
// 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.
/**
Overview
- Tests the health checks of the extension: provider-alicloud.
- Manipulates health check relevant resources and expects the extension-provider to properly report the results as conditions in the respective CRD (ControlPlane(Type Normal) & Worker CRD).
Prerequisites
- A Shoot exists.
Test-cases:
1) ControlPlane
1.1) HealthCondition Type: Shoot ControlPlaneHealthy
- delete the deployment 'cloud-controller-manager' and verify health check conditions in the ControlPlane status.
1.2) HealthCondition Type: Shoot SystemComponentsHealthy
- update the ManagedResource 'extension-controlplane-shoot' with an unhealthy condition and verify health check conditions in the ControlPlane status.
2) Worker
2.1) HealthCondition Type: Shoot ControlPlaneHealthy
- delete the deployment 'machine-controller-manager' and verify health check conditions in the Worker status.
2.2) HealthCondition Type: Shoot SystemComponentsHealthy
- update the ManagedResource 'extension-worker-mcm-shoot' with an unhealthy condition and verify health check conditions in the Worker status.
2.3) HealthCondition Type: Shoot EveryNodeReady
- delete a machine of the shoot cluster and verify the health check conditions in the Worker status report a missing node.
**/
package healthcheck
import (
"context"
"fmt"
"time"
"github.com/gardener/gardener-extension-provider-alicloud/pkg/alicloud"
genericcontrolplaneactuator "github.com/gardener/gardener/extensions/pkg/controller/controlplane/genericactuator"
genericworkeractuator "github.com/gardener/gardener/extensions/pkg/controller/worker/genericactuator"
healthcheckoperation "github.com/gardener/gardener/extensions/test/integration/healthcheck"
gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
"github.com/gardener/gardener/pkg/client/kubernetes"
"github.com/gardener/gardener/test/framework"
machinev1alpha1 "github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1"
"github.com/onsi/ginkgo"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)
const (
timeout = 10 * time.Minute
nodeRecreationTimeout = 20 * time.Minute
setupContextTimeout = 2 * time.Minute
)
var _ = ginkgo.Describe("Provider-alicloud integration test: health checks", func() {
f := createShootFramework()
ginkgo.Context("ControlPlane", func() {
ginkgo.Context("Condition type: ShootControlPlaneHealthy", func() {
f.Serial().Release().CIt(fmt.Sprintf("ControlPlane CRD should contain unhealthy condition because the deployment '%s' cannot be found in the shoot namespace in the seed", alicloud.CloudControllerManagerName), func(ctx context.Context) {
err := healthcheckoperation.ControlPlaneHealthCheckDeleteSeedDeployment(ctx, f, f.Shoot.GetName(), alicloud.CloudControllerManagerName, gardencorev1beta1.ShootControlPlaneHealthy)
framework.ExpectNoError(err)
}, timeout)
})
ginkgo.Context("Condition type: ShootControlPlaneHealthy", func() {
f.Serial().Release().CIt(fmt.Sprintf("ControlPlane CRD should contain unhealthy condition because the deployment '%s' cannot be found in the shoot namespace in the seed", alicloud.CSIPluginController), func(ctx context.Context) {
err := healthcheckoperation.ControlPlaneHealthCheckDeleteSeedDeployment(ctx, f, f.Shoot.GetName(), alicloud.CSIPluginController, gardencorev1beta1.ShootControlPlaneHealthy)
framework.ExpectNoError(err)
}, timeout)
})
ginkgo.Context("Condition type: ShootSystemComponentsHealthy", func() {
f.Serial().Release().CIt(fmt.Sprintf("ControlPlane CRD should contain unhealthy condition due to ManagedResource ('%s') unhealthy", genericcontrolplaneactuator.ControlPlaneShootChartResourceName), func(ctx context.Context) {
err := healthcheckoperation.ControlPlaneHealthCheckWithManagedResource(ctx, setupContextTimeout, f, genericcontrolplaneactuator.ControlPlaneShootChartResourceName, gardencorev1beta1.ShootSystemComponentsHealthy)
framework.ExpectNoError(err)
}, timeout)
})
})
ginkgo.Context("Worker", func() {
ginkgo.Context("Condition type: ShootControlPlaneHealthy", func() {
f.Serial().Release().CIt(fmt.Sprintf("Worker CRD should contain unhealthy condition because the deployment '%s' cannot be found in the shoot namespace in the seed", alicloud.MachineControllerManagerName), func(ctx context.Context) {
err := healthcheckoperation.WorkerHealthCheckDeleteSeedDeployment(ctx, f, f.Shoot.GetName(), alicloud.MachineControllerManagerName, gardencorev1beta1.ShootControlPlaneHealthy)
framework.ExpectNoError(err)
}, timeout)
})
ginkgo.Context("Condition type: ShootSystemComponentsHealthy", func() {
f.Serial().Release().CIt(fmt.Sprintf("Worker CRD should contain unhealthy condition due to ManagedResource ('%s') unhealthy", genericworkeractuator.McmShootResourceName), func(ctx context.Context) {
err := healthcheckoperation.WorkerHealthCheckWithManagedResource(ctx, setupContextTimeout, f, genericworkeractuator.McmShootResourceName, gardencorev1beta1.ShootSystemComponentsHealthy)
framework.ExpectNoError(err)
}, timeout)
})
ginkgo.Context("Condition type: ShootEveryNodeReady", func() {
f.Serial().Release().CIt("Worker CRD should contain unhealthy condition because not enough machines are available", func(ctx context.Context) {
err := healthcheckoperation.MachineDeletionHealthCheck(ctx, f)
framework.ExpectNoError(err)
}, nodeRecreationTimeout)
})
})
})
func createShootFramework() *framework.ShootFramework {
extensionSeedScheme := kubernetes.SeedScheme
seedSchemeBuilder := runtime.NewSchemeBuilder(
machinev1alpha1.AddToScheme,
)
utilruntime.Must(seedSchemeBuilder.AddToScheme(extensionSeedScheme))
return framework.NewShootFramework(&framework.ShootConfig{
SeedScheme: nil,
})
}