Skip to content

Commit 38eea9f

Browse files
authored
Add more e2e tests with example controller (#519)
* Extend test cases for verifying the setup * Add tests case with many objects * Add test case for removing shard * Add test case for adding shard * Add test case for graceful shard termination * Add test case for shard failure detection
1 parent eb9b870 commit 38eea9f

File tree

5 files changed

+311
-26
lines changed

5 files changed

+311
-26
lines changed

cmd/checksum-controller/reconciler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto/sha256"
2222
"encoding/hex"
2323
"fmt"
24+
"maps"
2425

2526
corev1 "k8s.io/api/core/v1"
2627
apiequality "k8s.io/apimachinery/pkg/api/equality"
@@ -112,6 +113,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
112113
ObjectMeta: metav1.ObjectMeta{
113114
Name: "checksums-" + secret.Name,
114115
Namespace: secret.Namespace,
116+
Labels: maps.Clone(secret.Labels),
115117
},
116118
Data: make(map[string]string, len(secret.Data)),
117119
}

hack/test-e2e.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set -o errexit
66

77
source "$(dirname "$0")/test-e2e.env"
88

9-
ginkgo run --timeout=1h --poll-progress-after=60s --poll-progress-interval=30s --randomize-all --randomize-suites --keep-going --vv "$@"
9+
ginkgo run --timeout=1h --poll-progress-after=60s --poll-progress-interval=30s --randomize-all --randomize-suites --keep-going -v --show-node-events "$@"

pkg/utils/test/matchers/object.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,26 @@ import (
2222
)
2323

2424
// HaveName succeeds if the actual object has a matching name.
25-
func HaveName(name interface{}) gomegatypes.GomegaMatcher {
25+
func HaveName(name string) gomegatypes.GomegaMatcher {
2626
return HaveField("ObjectMeta.Name", name)
2727
}
2828

29+
// HaveNames succeeds if the actual list consists of matching names.
30+
func HaveNames(names ...string) gomegatypes.GomegaMatcher {
31+
matchers := make([]any, len(names))
32+
for i, n := range names {
33+
matchers[i] = HaveName(n)
34+
}
35+
36+
return HaveField("Items", ConsistOf(matchers...))
37+
}
38+
2939
// HaveLabel succeeds if the actual object has a label with a matching key.
30-
func HaveLabel(key interface{}) gomegatypes.GomegaMatcher {
40+
func HaveLabel(key any) gomegatypes.GomegaMatcher {
3141
return HaveField("ObjectMeta.Labels", HaveKey(key))
3242
}
3343

3444
// HaveLabelWithValue succeeds if the actual object has a label with a matching key and value.
35-
func HaveLabelWithValue(key, value interface{}) gomegatypes.GomegaMatcher {
45+
func HaveLabelWithValue(key, value any) gomegatypes.GomegaMatcher {
3646
return HaveField("ObjectMeta.Labels", HaveKeyWithValue(key, value))
3747
}

test/e2e/e2e_suite_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ var _ = BeforeSuite(func() {
6969

7070
restConfig, err := config.GetConfig()
7171
Expect(err).NotTo(HaveOccurred())
72+
// gotta go fast during tests
73+
restConfig.QPS = 100
74+
restConfig.Burst = 150
7275

7376
scheme := runtime.NewScheme()
7477
schemeBuilder := runtime.NewSchemeBuilder(

0 commit comments

Comments
 (0)