Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add Expiration testing for E2E for v1beta1 #4887

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
suite: [Beta/Integration, Beta/Drift, Beta/Consolidation, Beta/NodeClaim, Alpha/Integration, Alpha/Machine, Alpha/Consolidation, Alpha/Utilization, Alpha/Interruption, Alpha/Drift, Alpha/Expiration, Alpha/Chaos, Alpha/IPv6]
suite: [Beta/Integration, Beta/Drift, Beta/Consolidation, Beta/Expiration, Beta/NodeClaim, Alpha/Integration, Alpha/Machine, Alpha/Consolidation, Alpha/Utilization, Alpha/Interruption, Alpha/Drift, Alpha/Expiration, Alpha/Chaos, Alpha/IPv6]
uses: ./.github/workflows/e2e.yaml
with:
suite: ${{ matrix.suite }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ on:
- Beta/Integration
- Beta/Drift
- Beta/Consolidation
- Beta/Expiration
- Beta/NodeClaim
- Alpha/Integration
- Alpha/Machine
- Alpha/Consolidation
Expand Down
8 changes: 8 additions & 0 deletions test/pkg/environment/common/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

coreapis "github.com/aws/karpenter-core/pkg/apis"
"github.com/aws/karpenter-core/pkg/apis/v1beta1"
"github.com/aws/karpenter-core/pkg/operator"
"github.com/aws/karpenter-core/pkg/operator/injection"
"github.com/aws/karpenter/pkg/apis"
Expand Down Expand Up @@ -116,6 +117,13 @@ func NewClient(ctx context.Context, config *rest.Config) client.Client {
node := o.(*v1.Node)
return []string{strconv.FormatBool(node.Spec.Unschedulable)}
}))
lo.Must0(cache.IndexField(ctx, &v1.Node{}, "spec.taints[*].karpenter.sh/disruption", func(o client.Object) []string {
node := o.(*v1.Node)
t, _ := lo.Find(node.Spec.Taints, func(t v1.Taint) bool {
return t.Key == v1beta1.DisruptionTaintKey
})
return []string{t.Value}
}))

c := lo.Must(client.New(config, client.Options{Scheme: scheme, Cache: &client.CacheOptions{Reader: cache}}))

Expand Down
36 changes: 35 additions & 1 deletion test/pkg/environment/common/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func (env *Environment) ConsistentlyExpectMachineCount(comparator string, count
return lo.ToSlicePtr(machineList.Items)
}

func (env *Environment) EventuallyExpectCordonedNodeCount(comparator string, count int) []*v1.Node {
func (env *Environment) EventuallyExpectCordonedNodeCountLegacy(comparator string, count int) []*v1.Node {
GinkgoHelper()
By(fmt.Sprintf("waiting for cordoned nodes to be %s to %d", comparator, count))
nodeList := &v1.NodeList{}
Expand All @@ -472,6 +472,40 @@ func (env *Environment) EventuallyExpectCordonedNodeCount(comparator string, cou
return lo.ToSlicePtr(nodeList.Items)
}

func (env *Environment) EventuallyExpectNodesUncordonedLegacyWithTimeout(timeout time.Duration, nodes ...*v1.Node) {
GinkgoHelper()
By(fmt.Sprintf("waiting for %d nodes to be uncordoned", len(nodes)))
nodeList := &v1.NodeList{}
Eventually(func(g Gomega) {
g.Expect(env.Client.List(env, nodeList, client.MatchingFields{"spec.unschedulable": "true"})).To(Succeed())
cordonedNodeNames := lo.Map(nodeList.Items, func(n v1.Node, _ int) string { return n.Name })
g.Expect(cordonedNodeNames).ToNot(ContainElements(lo.Map(nodes, func(n *v1.Node, _ int) interface{} { return n.Name })...))
}).WithTimeout(timeout).Should(Succeed())
}

func (env *Environment) EventuallyExpectCordonedNodeCount(comparator string, count int) []*v1.Node {
GinkgoHelper()
By(fmt.Sprintf("waiting for cordoned nodes to be %s to %d", comparator, count))
nodeList := &v1.NodeList{}
Eventually(func(g Gomega) {
g.Expect(env.Client.List(env, nodeList, client.MatchingFields{"spec.taints[*].karpenter.sh/disruption": "disrupting"})).To(Succeed())
g.Expect(len(nodeList.Items)).To(BeNumerically(comparator, count),
fmt.Sprintf("expected %d cordoned nodes, had %d (%v)", count, len(nodeList.Items), NodeNames(lo.ToSlicePtr(nodeList.Items))))
}).Should(Succeed())
return lo.ToSlicePtr(nodeList.Items)
}

func (env *Environment) EventuallyExpectNodesUncordonedWithTimeout(timeout time.Duration, nodes ...*v1.Node) {
GinkgoHelper()
By(fmt.Sprintf("waiting for %d nodes to be uncordoned", len(nodes)))
nodeList := &v1.NodeList{}
Eventually(func(g Gomega) {
g.Expect(env.Client.List(env, nodeList, client.MatchingFields{"spec.taints[*].karpenter.sh/disruption": "disrupting"})).To(Succeed())
cordonedNodeNames := lo.Map(nodeList.Items, func(n v1.Node, _ int) string { return n.Name })
g.Expect(cordonedNodeNames).ToNot(ContainElements(lo.Map(nodes, func(n *v1.Node, _ int) interface{} { return n.Name })...))
}).WithTimeout(timeout).Should(Succeed())
}

func (env *Environment) EventuallyExpectNodeCount(comparator string, count int) []*v1.Node {
GinkgoHelper()
By(fmt.Sprintf("waiting for nodes to be %s to %d", comparator, count))
Expand Down