-
Notifications
You must be signed in to change notification settings - Fork 162
/
scyllacluster_evictions.go
65 lines (53 loc) · 2.22 KB
/
scyllacluster_evictions.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
// Copyright (C) 2021 ScyllaDB
package scyllacluster
import (
"context"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
scyllafixture "github.com/scylladb/scylla-operator/test/e2e/fixture/scylla"
"github.com/scylladb/scylla-operator/test/e2e/framework"
"github.com/scylladb/scylla-operator/test/e2e/utils"
policyv1beta1 "k8s.io/api/policy/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var _ = g.Describe("ScyllaCluster evictions", func() {
defer g.GinkgoRecover()
f := framework.NewFramework("scyllacluster")
g.It("should allow one disruption", func() {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
sc := scyllafixture.BasicScyllaCluster.ReadOrFail()
sc.Spec.Datacenter.Racks[0].Members = 2
framework.By("Creating a ScyllaCluster")
sc, err := f.ScyllaClient().ScyllaV1().ScyllaClusters(f.Namespace()).Create(ctx, sc, metav1.CreateOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
framework.By("Waiting for the ScyllaCluster to rollout (RV=%s)", sc.ResourceVersion)
waitCtx1, waitCtx1Cancel := utils.ContextForRollout(ctx, sc)
defer waitCtx1Cancel()
sc, err = utils.WaitForScyllaClusterState(waitCtx1, f.ScyllaClient().ScyllaV1(), sc.Namespace, sc.Name, utils.WaitForStateOptions{}, utils.IsScyllaClusterRolledOut)
o.Expect(err).NotTo(o.HaveOccurred())
verifyScyllaCluster(ctx, f.KubeClient(), sc)
hosts := getScyllaHostsAndWaitForFullQuorum(ctx, f.KubeClient().CoreV1(), sc)
o.Expect(hosts).To(o.HaveLen(2))
di := insertAndVerifyCQLData(ctx, hosts)
defer di.Close()
framework.By("Allowing the first pod to be evicted")
e := &policyv1beta1.Eviction{
ObjectMeta: metav1.ObjectMeta{
Name: utils.GetNodeName(sc, 0),
Namespace: f.Namespace(),
},
}
err = f.KubeAdminClient().CoreV1().Pods(f.Namespace()).Evict(ctx, e)
o.Expect(err).NotTo(o.HaveOccurred())
framework.By("Forbidding to evict a second pod")
e = &policyv1beta1.Eviction{
ObjectMeta: metav1.ObjectMeta{
Name: utils.GetNodeName(sc, 1),
Namespace: f.Namespace(),
},
}
err = f.KubeAdminClient().CoreV1().Pods(f.Namespace()).Evict(ctx, e)
o.Expect(err).Should(o.MatchError("Cannot evict pod as it would violate the pod's disruption budget."))
})
})