12
12
import static io .apicurio .registry .operator .it .SmokeITTest .ingressDisabled ;
13
13
import static io .apicurio .registry .operator .resource .ResourceFactory .*;
14
14
import static io .restassured .RestAssured .given ;
15
- import static org .assertj .core .api .Assertions .assertThat ;
16
15
import static org .awaitility .Awaitility .await ;
17
16
18
17
@ QuarkusTest
@@ -36,8 +35,8 @@ void smoke() {
36
35
37
36
client .resource (simpleRegistry ).create ();
38
37
39
- checkDeploymentExists (simpleRegistry , COMPONENT_APP );
40
- checkDeploymentExists (simpleRegistry , COMPONENT_UI );
38
+ checkDeploymentExists (simpleRegistry , COMPONENT_APP , 1 );
39
+ checkDeploymentExists (simpleRegistry , COMPONENT_UI , 1 );
41
40
checkDeploymentDoesNotExist (simpleRegistry , COMPONENT_STUDIO_UI );
42
41
43
42
checkServiceExists (simpleRegistry , COMPONENT_APP );
@@ -52,9 +51,9 @@ void smoke() {
52
51
simpleRegistry .getSpec ().withStudioUi ().setEnabled (true );
53
52
client .resource (simpleRegistry ).update ();
54
53
55
- checkDeploymentExists (simpleRegistry , COMPONENT_APP );
56
- checkDeploymentExists (simpleRegistry , COMPONENT_UI );
57
- checkDeploymentExists (simpleRegistry , COMPONENT_STUDIO_UI );
54
+ checkDeploymentExists (simpleRegistry , COMPONENT_APP , 1 );
55
+ checkDeploymentExists (simpleRegistry , COMPONENT_UI , 1 );
56
+ checkDeploymentExists (simpleRegistry , COMPONENT_STUDIO_UI , 1 );
58
57
59
58
checkServiceExists (simpleRegistry , COMPONENT_APP );
60
59
checkServiceExists (simpleRegistry , COMPONENT_UI );
@@ -96,9 +95,9 @@ void smoke() {
96
95
simpleRegistry .getSpec ().getStudioUi ().getIngress ().setHost (null );
97
96
client .resource (simpleRegistry ).update ();
98
97
99
- checkDeploymentExists (simpleRegistry , COMPONENT_APP );
100
- checkDeploymentExists (simpleRegistry , COMPONENT_UI );
101
- checkDeploymentExists (simpleRegistry , COMPONENT_STUDIO_UI );
98
+ checkDeploymentExists (simpleRegistry , COMPONENT_APP , 1 );
99
+ checkDeploymentExists (simpleRegistry , COMPONENT_UI , 1 );
100
+ checkDeploymentExists (simpleRegistry , COMPONENT_STUDIO_UI , 1 );
102
101
103
102
checkServiceExists (simpleRegistry , COMPONENT_APP );
104
103
checkServiceExists (simpleRegistry , COMPONENT_UI );
@@ -112,8 +111,8 @@ void smoke() {
112
111
simpleRegistry .getSpec ().getStudioUi ().setEnabled (false );
113
112
client .resource (simpleRegistry ).update ();
114
113
115
- checkDeploymentExists (simpleRegistry , COMPONENT_APP );
116
- checkDeploymentExists (simpleRegistry , COMPONENT_UI );
114
+ checkDeploymentExists (simpleRegistry , COMPONENT_APP , 1 );
115
+ checkDeploymentExists (simpleRegistry , COMPONENT_UI , 1 );
117
116
checkDeploymentDoesNotExist (simpleRegistry , COMPONENT_STUDIO_UI );
118
117
119
118
checkServiceExists (simpleRegistry , COMPONENT_APP );
@@ -125,49 +124,37 @@ void smoke() {
125
124
checkIngressDoesNotExist (simpleRegistry , COMPONENT_STUDIO_UI );
126
125
}
127
126
128
- private static void checkDeploymentExists (ApicurioRegistry3 primary , String component ) {
129
- await ().ignoreExceptions ().untilAsserted (() -> {
130
- assertThat (client .apps ().deployments ()
131
- .withName (primary .getMetadata ().getName () + "-" + component + "-deployment" ).get ()
132
- .getStatus ().getReadyReplicas ()).isEqualTo (1 );
133
- });
134
- }
127
+ /**
128
+ * Scenario: We want to check that the Studio component is not deployed by default unless the enabled
129
+ * field is set to true, and, when activated, the number of replicas is set to the value specified while
130
+ * checking that the basic Kubernetes resources are deployed as expected. We do not check Registry
131
+ * components in detail, because that's done in other tests.
132
+ */
133
+ @ Test
134
+ void replicas () {
135
+ var simpleRegistry = ResourceFactory .deserialize ("/k8s/examples/simple.apicurioregistry3.yaml" ,
136
+ ApicurioRegistry3 .class );
135
137
136
- private static void checkDeploymentDoesNotExist (ApicurioRegistry3 primary , String component ) {
137
- await ().ignoreExceptions ().untilAsserted (() -> {
138
- assertThat (client .apps ().deployments ()
139
- .withName (primary .getMetadata ().getName () + "-" + component + "-deployment" ).get ())
140
- .isNull ();
141
- });
142
- }
138
+ simpleRegistry .getMetadata ().setNamespace (namespace );
139
+ simpleRegistry .getSpec ().getApp ().setHost (ingressManager .getIngressHost (COMPONENT_APP ));
140
+ simpleRegistry .getSpec ().getUi ().setHost (ingressManager .getIngressHost (COMPONENT_UI ));
143
141
144
- private static void checkServiceExists (ApicurioRegistry3 primary , String component ) {
145
- await ().ignoreExceptions ().untilAsserted (() -> {
146
- assertThat (client .services ()
147
- .withName (primary .getMetadata ().getName () + "-" + component + "-service" ).get ())
148
- .isNotNull ();
149
- });
150
- }
142
+ client .resource (simpleRegistry ).create ();
151
143
152
- private static void checkServiceDoesNotExist (ApicurioRegistry3 primary , String component ) {
153
- await ().ignoreExceptions ().untilAsserted (() -> {
154
- assertThat (client .services ()
155
- .withName (primary .getMetadata ().getName () + "-" + component + "-service" ).get ()).isNull ();
156
- });
157
- }
144
+ // We start with one replica for Registry
145
+ checkDeploymentExists (simpleRegistry , COMPONENT_APP , 1 );
146
+ checkDeploymentExists (simpleRegistry , COMPONENT_UI , 1 );
147
+ checkDeploymentDoesNotExist (simpleRegistry , COMPONENT_STUDIO_UI );
158
148
159
- private static void checkIngressExists (ApicurioRegistry3 primary , String component ) {
160
- await ().ignoreExceptions ().untilAsserted (() -> {
161
- assertThat (client .network ().v1 ().ingresses ()
162
- .withName (primary .getMetadata ().getName () + "-" + component + "-ingress" ).get ())
163
- .isNotNull ();
164
- });
165
- }
149
+ // Now let's enable the Studio component and scale Registry to 3 replicas
150
+ simpleRegistry .getSpec ().withStudioUi ().setEnabled (true );
151
+ simpleRegistry .getSpec ().getApp ().setReplicas (3 );
152
+ simpleRegistry .getSpec ().getUi ().setReplicas (3 );
153
+ simpleRegistry .getSpec ().getStudioUi ().setReplicas (3 );
154
+ client .resource (simpleRegistry ).update ();
166
155
167
- private static void checkIngressDoesNotExist (ApicurioRegistry3 primary , String component ) {
168
- await ().ignoreExceptions ().untilAsserted (() -> {
169
- assertThat (client .network ().v1 ().ingresses ()
170
- .withName (primary .getMetadata ().getName () + "-" + component + "-ingress" ).get ()).isNull ();
171
- });
156
+ checkDeploymentExists (simpleRegistry , COMPONENT_APP , 3 );
157
+ checkDeploymentExists (simpleRegistry , COMPONENT_UI , 3 );
158
+ checkDeploymentExists (simpleRegistry , COMPONENT_STUDIO_UI , 3 );
172
159
}
173
160
}
0 commit comments