-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Testing for Repair Policy CP interface
- Loading branch information
Showing
4 changed files
with
112 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
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 integration_test | ||
|
||
import ( | ||
"time" | ||
|
||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/labels" | ||
karpenterv1 "sigs.k8s.io/karpenter/pkg/apis/v1" | ||
coretest "sigs.k8s.io/karpenter/pkg/test" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
"github.com/samber/lo" | ||
) | ||
|
||
var _ = Describe("Repair Policy", func() { | ||
var selector labels.Selector | ||
var dep *appsv1.Deployment | ||
var numPods int | ||
|
||
BeforeEach(func() { | ||
numPods = 1 | ||
// Add pods with a do-not-disrupt annotation so that we can check node metadata before we disrupt | ||
dep = coretest.Deployment(coretest.DeploymentOptions{ | ||
Replicas: int32(numPods), | ||
PodOptions: coretest.PodOptions{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: map[string]string{ | ||
"app": "my-app", | ||
}, | ||
Annotations: map[string]string{ | ||
karpenterv1.DoNotDisruptAnnotationKey: "true", | ||
}, | ||
}, | ||
TerminationGracePeriodSeconds: lo.ToPtr[int64](0), | ||
}, | ||
}) | ||
selector = labels.SelectorFromSet(dep.Spec.Selector.MatchLabels) | ||
}) | ||
|
||
FDescribeTable("Conditions", func(unhealthyCondition corev1.NodeCondition) { | ||
env.ExpectCreated(nodeClass, nodePool, dep) | ||
pod := env.EventuallyExpectHealthyPodCount(selector, numPods)[0] | ||
node := env.ExpectCreatedNodeCount("==", 1)[0] | ||
env.EventuallyExpectInitializedNodeCount("==", 1) | ||
|
||
node.Status.Conditions = append(node.Status.Conditions, unhealthyCondition) | ||
|
||
env.ExpectStatusUpdated(node) | ||
|
||
env.EventuallyExpectNotFound(pod, node) | ||
env.EventuallyExpectHealthyPodCount(selector, numPods) | ||
}, | ||
Entry("Kubelet Readiness", corev1.NodeCondition{ | ||
Type: corev1.NodeReady, | ||
Status: corev1.ConditionFalse, | ||
LastTransitionTime: metav1.Time{Time: time.Now().Add(-30 * time.Minute)}, | ||
}), | ||
Entry("Kubelet DiskPressure", corev1.NodeCondition{ | ||
Type: corev1.NodeDiskPressure, | ||
Status: corev1.ConditionTrue, | ||
LastTransitionTime: metav1.Time{Time: time.Now().Add(-30 * time.Minute)}, | ||
}), | ||
Entry("Kubelet MemoryPressure", corev1.NodeCondition{ | ||
Type: corev1.NodeMemoryPressure, | ||
Status: corev1.ConditionTrue, | ||
LastTransitionTime: metav1.Time{Time: time.Now().Add(-30 * time.Minute)}, | ||
}), | ||
) | ||
}) |