Skip to content

Commit 9e0e26f

Browse files
authored
Add .svc suffix to make URI's consistently valid (#4132)
1 parent 9972326 commit 9e0e26f

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

operator/src/main/java/oracle/kubernetes/operator/steps/HttpRequestProcessing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private String getHost() {
131131

132132
private String toServiceHost(@Nonnull V1ObjectMeta meta) {
133133
String ns = Optional.ofNullable(meta.getNamespace()).orElse("default");
134-
return meta.getName() + "." + ns;
134+
return meta.getName() + "." + ns + ".svc";
135135
}
136136

137137
protected V1Pod getPod() {

operator/src/test/java/oracle/kubernetes/operator/DomainProcessorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ private void defineServerShutdownWithHttpOkResponse() {
646646
}
647647

648648
private HttpRequest createShutdownRequest(String serverName, int portNumber) {
649-
String url = "http://test-domain-" + serverName + ".namespace:" + portNumber;
649+
String url = "http://test-domain-" + serverName + ".namespace.svc:" + portNumber;
650650
return HttpRequest.newBuilder()
651651
.uri(URI.create(url + "/management/weblogic/latest/serverRuntime/shutdown"))
652652
.POST(HttpRequest.BodyPublishers.noBody())
@@ -739,7 +739,7 @@ private V1Secret createCredentialsSecret() {
739739

740740
@SuppressWarnings("HttpUrlsUsage")
741741
private void defineOKResponse(@Nonnull String serverName, int port) {
742-
final String url = "http://" + UID + "-" + serverName + "." + NS + ":" + port;
742+
final String url = "http://" + UID + "-" + serverName + "." + NS + ".svc:" + port;
743743
httpSupport.defineResponse(createExpectedRequest(url), createStub(HttpResponseStub.class, HTTP_OK, OK_RESPONSE));
744744
}
745745

operator/src/test/java/oracle/kubernetes/operator/steps/MonitoringExporterStepsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.steps;
@@ -188,7 +188,7 @@ private void expectConfigurationUpdate(String serverName) {
188188

189189
@Nonnull
190190
private String getExporterHost(String serverName) {
191-
return DOMAIN_NAME + "-" + serverName + "." + NS;
191+
return DOMAIN_NAME + "-" + serverName + "." + NS + ".svc";
192192
}
193193

194194
@Nonnull

operator/src/test/java/oracle/kubernetes/operator/steps/ReadHealthStepTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.steps;
@@ -137,7 +137,7 @@ public void tearDown() {
137137
@Test
138138
void whenReadAdminServerHealth_decrementRemainingServers() {
139139
selectServer(ADMIN_NAME);
140-
defineResponse(200, OK_RESPONSE, "http://" + ADMIN_NAME + ".Test:3456");
140+
defineResponse(200, OK_RESPONSE, "http://" + ADMIN_NAME + ".Test.svc:3456");
141141

142142
Packet packet = testSupport.runSteps(readHealthStep);
143143

@@ -155,7 +155,7 @@ private void defineResponse(int status, String body, @Nonnull String url) {
155155
void whenReadConfiguredManagedServerHealth_decrementRemainingServers() {
156156
V1Service service = selectServer(CONFIGURED_MANAGED_SERVER1);
157157
configureServiceWithClusterName(CONFIGURED_CLUSTER_NAME, service);
158-
defineResponse(200, OK_RESPONSE, "http://" + CONFIGURED_MANAGED_SERVER1 + ".Test:7001");
158+
defineResponse(200, OK_RESPONSE, "http://" + CONFIGURED_MANAGED_SERVER1 + ".Test.svc:7001");
159159

160160
Packet packet = testSupport.runSteps(readHealthStep);
161161

@@ -169,7 +169,7 @@ void whenReadConfiguredManagedServerHealth_decrementRemainingServers() {
169169
void whenReadDynamicManagedServerHealth_decrementRemainingServers() {
170170
V1Service service = selectServer(DYNAMIC_MANAGED_SERVER1);
171171
configureServiceWithClusterName(DYNAMIC_CLUSTER_NAME, service);
172-
defineResponse(200, OK_RESPONSE, "http://" + DYNAMIC_MANAGED_SERVER1 + ".Test:7001");
172+
defineResponse(200, OK_RESPONSE, "http://" + DYNAMIC_MANAGED_SERVER1 + ".Test.svc:7001");
173173

174174
Packet packet = testSupport.runSteps(readHealthStep);
175175

@@ -180,7 +180,7 @@ void whenReadDynamicManagedServerHealth_decrementRemainingServers() {
180180
void whenServerRunning_verifyServerHealth() {
181181
selectServer(MANAGED_SERVER1);
182182

183-
defineResponse(200, OK_RESPONSE, "http://" + MANAGED_SERVER1 + ".Test:8001");
183+
defineResponse(200, OK_RESPONSE, "http://" + MANAGED_SERVER1 + ".Test.svc:8001");
184184

185185
Packet packet = testSupport.runSteps(readHealthStep);
186186

@@ -199,7 +199,7 @@ private Map<String, String> getServerStateMap(Packet packet) {
199199
@Test
200200
void whenAdminPodIPNull_verifyServerHealth() {
201201
selectServer(ADMIN_NAME);
202-
defineResponse(200, OK_RESPONSE, "http://admin-server.Test:3456");
202+
defineResponse(200, OK_RESPONSE, "http://admin-server.Test.svc:3456");
203203

204204
Packet packet = testSupport.runSteps(readHealthStep);
205205

@@ -209,7 +209,7 @@ void whenAdminPodIPNull_verifyServerHealth() {
209209
@Test
210210
void whenAdminPodIPNull_requestSendWithCredentials() {
211211
selectServer(ADMIN_NAME);
212-
defineResponse(200, OK_RESPONSE, "http://admin-server.Test:3456");
212+
defineResponse(200, OK_RESPONSE, "http://admin-server.Test.svc:3456");
213213

214214
testSupport.runSteps(readHealthStep);
215215

@@ -232,7 +232,7 @@ private String expectedAuthorizationHeader() {
232232
void whenServerOverloaded_verifyServerHealth() {
233233
selectServer(MANAGED_SERVER1);
234234

235-
defineResponse(500, "", "http://" + MANAGED_SERVER1 + ".Test:8001");
235+
defineResponse(500, "", "http://" + MANAGED_SERVER1 + ".Test.svc:8001");
236236

237237
Packet packet = testSupport.runSteps(readHealthStep);
238238

@@ -245,7 +245,7 @@ void whenServerOverloaded_verifyServerHealth() {
245245
void whenUnableToReadHealth_verifyNotAvailable() {
246246
selectServer(MANAGED_SERVER1);
247247

248-
defineResponse(404, "", "http://" + MANAGED_SERVER1 + ".Test:8001");
248+
defineResponse(404, "", "http://" + MANAGED_SERVER1 + ".Test.svc:8001");
249249

250250
Packet packet = testSupport.runSteps(readHealthStep);
251251

@@ -394,15 +394,15 @@ void whenAuthorizedToReadHealthAndThenWait_verifySecretCleared() {
394394
void whenNotAuthorizedToReadHealth_verifySecretCleared() {
395395
selectServer(MANAGED_SERVER1);
396396

397-
defineResponse(403, "", "http://" + MANAGED_SERVER1 + ".Test:8001");
397+
defineResponse(403, "", "http://" + MANAGED_SERVER1 + ".Test.svc:8001");
398398

399399
testSupport.runSteps(readHealthStep);
400400

401401
assertThat(info.getWebLogicCredentialsSecret(), is(nullValue()));
402402
}
403403

404404
private void defineExpectedURLInResponse(String protocol, int port) {
405-
defineResponse(200, OK_RESPONSE, protocol + "://dyn-managed-server2.Test:" + port);
405+
defineResponse(200, OK_RESPONSE, protocol + "://dyn-managed-server2.Test.svc:" + port);
406406
}
407407

408408
private boolean readServerHealthSucceeded(Packet packet) {

operator/src/test/java/oracle/kubernetes/operator/steps/ShutdownManagedServerStepTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private void addEnvVar(List<V1EnvVar> vars, String name, String value) {
227227
void whenAuthorizedToInvokeShutdown_verifySecretSet() {
228228
selectServer(CONFIGURED_MANAGED_SERVER1, configuredServerService);
229229

230-
defineResponse(200, "http://test-domain-conf-managed-server1.namespace:7001");
230+
defineResponse(200, "http://test-domain-conf-managed-server1.namespace.svc:7001");
231231

232232
// Validate not set before running steps
233233
assertThat(info.getWebLogicCredentialsSecret(), is(nullValue()));
@@ -243,7 +243,7 @@ void whenAuthorizedToInvokeShutdown_verifySecretSet() {
243243
void whenInvokeShutdown_configuredClusterServer_verifySuccess() {
244244
selectServer(CONFIGURED_MANAGED_SERVER1, configuredServerService);
245245

246-
defineResponse(200, "http://test-domain-conf-managed-server1.namespace:7001");
246+
defineResponse(200, "http://test-domain-conf-managed-server1.namespace.svc:7001");
247247

248248
testSupport.runSteps(shutdownConfiguredManagedServer);
249249

@@ -254,7 +254,7 @@ void whenInvokeShutdown_configuredClusterServer_verifySuccess() {
254254
void whenInvokeShutdown_configuredClusterServer_verifyFailure() {
255255
selectServer(CONFIGURED_MANAGED_SERVER1, configuredServerService);
256256

257-
defineResponse(404, "http://test-domain-conf-managed-server1.namespace:7001");
257+
defineResponse(404, "http://test-domain-conf-managed-server1.namespace.svc:7001");
258258

259259
testSupport.runSteps(shutdownConfiguredManagedServer);
260260

@@ -265,7 +265,7 @@ void whenInvokeShutdown_configuredClusterServer_verifyFailure() {
265265
void whenInvokeShutdown_standaloneServer_verifySuccess() {
266266
selectServer(MANAGED_SERVER1, standaloneServerService);
267267

268-
defineResponse(200, "http://test-domain-managed-server1.namespace:8001");
268+
defineResponse(200, "http://test-domain-managed-server1.namespace.svc:8001");
269269

270270
testSupport.runSteps(shutdownStandaloneManagedServer);
271271

@@ -276,7 +276,7 @@ void whenInvokeShutdown_standaloneServer_verifySuccess() {
276276
void whenInvokeShutdown_standaloneServer_verifyFailure() {
277277
selectServer(MANAGED_SERVER1, standaloneServerService);
278278

279-
defineResponse(404, "http://test-domain-managed-server1.namespace:7001");
279+
defineResponse(404, "http://test-domain-managed-server1.namespace.svc:7001");
280280

281281
testSupport.runSteps(shutdownStandaloneManagedServer);
282282

@@ -287,7 +287,7 @@ void whenInvokeShutdown_standaloneServer_verifyFailure() {
287287
void whenInvokeShutdown_standaloneServer_DomainNotFound_verifyFailureAndRunNextStep() {
288288
selectServer(MANAGED_SERVER1, standaloneServerService);
289289

290-
defineResponse(404, "http://test-domain-managed-server1.namespace:7001");
290+
defineResponse(404, "http://test-domain-managed-server1.namespace.svc:7001");
291291
testSupport.failOnResource(KubernetesTestSupport.DOMAIN, UID, NS, HTTP_NOT_FOUND);
292292

293293
testSupport.runSteps(shutdownStandaloneManagedServer);
@@ -300,7 +300,7 @@ void whenInvokeShutdown_standaloneServer_DomainNotFound_verifyFailureAndRunNextS
300300
void whenInvokeShutdown_dynamicServer_verifySuccess() {
301301
selectServer(DYNAMIC_MANAGED_SERVER1, dynamicServerService);
302302

303-
defineResponse(200, "http://test-domain-dyn-managed-server1.namespace:7001");
303+
defineResponse(200, "http://test-domain-dyn-managed-server1.namespace.svc:7001");
304304

305305
testSupport.runSteps(shutdownDynamicManagedServer);
306306

@@ -311,7 +311,7 @@ void whenInvokeShutdown_dynamicServer_verifySuccess() {
311311
void whenInvokeShutdown_dynamicServer_verifyFailure() {
312312
selectServer(DYNAMIC_MANAGED_SERVER1, dynamicServerService);
313313

314-
defineResponse(404, "http://test-domain-dyn-managed-server1.namespace:8001");
314+
defineResponse(404, "http://test-domain-dyn-managed-server1.namespace.svc:8001");
315315

316316
testSupport.runSteps(shutdownDynamicManagedServer);
317317

@@ -323,7 +323,7 @@ void whenInvokeForceShutdown_standaloneServer_verifySuccess() {
323323
selectServer(MANAGED_SERVER1, standaloneServerService);
324324
setForcedShutdownType(MANAGED_SERVER1);
325325

326-
defineResponse(false, 200, "http://test-domain-managed-server1.namespace:8001");
326+
defineResponse(false, 200, "http://test-domain-managed-server1.namespace.svc:8001");
327327

328328
testSupport.runSteps(shutdownStandaloneManagedServer);
329329

0 commit comments

Comments
 (0)