@@ -20,9 +20,14 @@ package e2e
20
20
import (
21
21
"context"
22
22
solrv1beta1 "github.com/apache/solr-operator/api/v1beta1"
23
+ "github.com/apache/solr-operator/controllers"
23
24
. "github.com/onsi/ginkgo/v2"
24
25
. "github.com/onsi/gomega"
26
+ appsv1 "k8s.io/api/apps/v1"
27
+ corev1 "k8s.io/api/core/v1"
25
28
"k8s.io/utils/pointer"
29
+ "sigs.k8s.io/controller-runtime/pkg/client"
30
+ "time"
26
31
)
27
32
28
33
var _ = FDescribe ("E2E - SolrCloud - Security JSON" , func () {
@@ -35,10 +40,6 @@ var _ = FDescribe("E2E - SolrCloud - Security JSON", func() {
35
40
})
36
41
37
42
JustBeforeEach (func (ctx context.Context ) {
38
- By ("generating the security.json secret and basic auth secret" )
39
- generateSolrSecuritySecret (ctx , solrCloud )
40
- generateSolrBasicAuthSecret (ctx , solrCloud )
41
-
42
43
By ("creating the SolrCloud" )
43
44
Expect (k8sClient .Create (ctx , solrCloud )).To (Succeed ())
44
45
@@ -50,20 +51,64 @@ var _ = FDescribe("E2E - SolrCloud - Security JSON", func() {
50
51
solrCloud = expectSolrCloudToBeReady (ctx , solrCloud )
51
52
52
53
By ("creating a first Solr Collection" )
53
- createAndQueryCollection (ctx , solrCloud , "basic" , 1 , 1 )
54
+ createAndQueryCollection (ctx , solrCloud , "basic" , 2 , 1 )
54
55
})
55
56
56
- FContext ("Provided Zookeeper " , func () {
57
- BeforeEach (func () {
57
+ FContext ("Provided Security JSON " , func () {
58
+ BeforeEach (func (ctx context. Context ) {
58
59
solrCloud .Spec .ZookeeperRef = & solrv1beta1.ZookeeperRef {
59
60
ProvidedZookeeper : & solrv1beta1.ZookeeperSpec {
60
61
Replicas : pointer .Int32 (1 ),
61
62
Ephemeral : & solrv1beta1.ZKEphemeral {},
62
63
},
63
64
}
65
+
66
+ solrCloud .Spec .SolrSecurity = & solrv1beta1.SolrSecurityOptions {
67
+ AuthenticationType : "Basic" ,
68
+ BasicAuthSecret : solrCloud .Name + "-basic-auth-secret" ,
69
+ BootstrapSecurityJson : & corev1.SecretKeySelector {
70
+ LocalObjectReference : corev1.LocalObjectReference {
71
+ Name : solrCloud .Name + "-security-secret" ,
72
+ },
73
+ Key : "security.json" ,
74
+ },
75
+ }
76
+
77
+ By ("generating the security.json secret and basic auth secret" )
78
+ generateSolrSecuritySecret (ctx , solrCloud )
79
+ generateSolrBasicAuthSecret (ctx , solrCloud )
64
80
})
65
81
66
82
// All testing will be done in the "JustBeforeEach" logic, no additional tests required here
67
83
FIt ("Starts correctly" , func (ctx context.Context ) {})
68
84
})
85
+
86
+ FContext ("Bootstrapped Security" , func () {
87
+
88
+ BeforeEach (func () {
89
+ solrCloud .Spec .SolrSecurity = & solrv1beta1.SolrSecurityOptions {
90
+ AuthenticationType : "Basic" ,
91
+ }
92
+ })
93
+
94
+ FIt ("Scales up with replica migration" , func (ctx context.Context ) {
95
+ originalSolrCloud := solrCloud .DeepCopy ()
96
+ solrCloud .Spec .Replicas = pointer .Int32 (int32 (2 ))
97
+ By ("triggering a scale up via solrCloud replicas" )
98
+ Expect (k8sClient .Patch (ctx , solrCloud , client .MergeFrom (originalSolrCloud ))).To (Succeed (), "Could not patch SolrCloud replicas to initiate scale down" )
99
+
100
+ By ("make sure scaleDown happens without a clusterLock and eventually the replicas are removed" )
101
+ // Once the scale down actually occurs, the statefulSet annotations should be removed very soon
102
+ expectStatefulSetWithChecksAndTimeout (ctx , solrCloud , solrCloud .StatefulSetName (), time .Minute * 2 , time .Millisecond * 500 , func (g Gomega , found * appsv1.StatefulSet ) {
103
+ g .Expect (found .Spec .Replicas ).To (HaveValue (BeEquivalentTo (2 )), "StatefulSet should eventually have 2 pods." )
104
+ clusterOp , err := controllers .GetCurrentClusterOp (found )
105
+ g .Expect (err ).ToNot (HaveOccurred (), "Error occurred while finding clusterLock for SolrCloud" )
106
+ g .Expect (clusterOp ).To (BeNil (), "StatefulSet should have a ScaleDown lock after scaling is complete." )
107
+ })
108
+
109
+ queryCollection (ctx , solrCloud , "basic" , 0 )
110
+
111
+ // TODO: When balancing is in all Operator supported Solr versions, add a test to make sure balancing occurred
112
+ })
113
+ })
69
114
})
0 commit comments