Skip to content

Commit f3c5194

Browse files
committed
Fix another unit-test to not load a real client
1 parent 142b84c commit f3c5194

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

operator/src/main/java/oracle/kubernetes/operator/ServerStatusReader.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2025, 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;
@@ -16,12 +16,10 @@
1616
import javax.annotation.Nonnull;
1717

1818
import io.kubernetes.client.extended.controller.reconciler.Result;
19-
import io.kubernetes.client.openapi.ApiClient;
2019
import io.kubernetes.client.openapi.ApiException;
2120
import io.kubernetes.client.openapi.models.V1ObjectMeta;
2221
import io.kubernetes.client.openapi.models.V1Pod;
2322
import oracle.kubernetes.common.logging.MessageKeys;
24-
import oracle.kubernetes.operator.calls.Client;
2523
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
2624
import oracle.kubernetes.operator.helpers.KubernetesUtils;
2725
import oracle.kubernetes.operator.helpers.LastKnownStatus;
@@ -166,13 +164,12 @@ private static class ServerStatusReaderStep extends Step {
166164
final boolean tty = false;
167165
Process proc = null;
168166
String state = null;
169-
ApiClient client = Client.getInstance();
170167

171168
try {
172169
try (ThreadLoggingContext stack =
173170
setThreadContext().namespace(getNamespace(currentPod)).domainUid(getDomainUid(currentPod))) {
174171

175-
KubernetesExec kubernetesExec = execFactory.create(client, currentPod, WLS_CONTAINER_NAME);
172+
KubernetesExec kubernetesExec = execFactory.create(currentPod, WLS_CONTAINER_NAME);
176173
kubernetesExec.setStdin(stdin);
177174
kubernetesExec.setTty(tty);
178175
proc = kubernetesExec.exec("/weblogic-operator/scripts/readState.sh");
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
// Copyright (c) 2019, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, 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.utils;
55

6-
import io.kubernetes.client.openapi.ApiClient;
76
import io.kubernetes.client.openapi.models.V1Pod;
87

98
/** A factory for objects which can execute commands in Kubernetes containers. */
109
public interface KubernetesExecFactory {
1110
/**
1211
* Creates an object to execute a command in a Kubernetes container.
1312
*
14-
* @param client the api client to dispatch the "exec" command
1513
* @param pod the pod which has the container in which the command should be run
1614
* @param containerName the container in which the command is to be run
1715
* @return the object to execute the command
1816
*/
19-
KubernetesExec create(ApiClient client, V1Pod pod, String containerName);
17+
KubernetesExec create(V1Pod pod, String containerName);
2018
}
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
// Copyright (c) 2019, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, 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.utils;
55

66
import java.io.IOException;
77

88
import io.kubernetes.client.Exec;
9-
import io.kubernetes.client.openapi.ApiClient;
109
import io.kubernetes.client.openapi.ApiException;
1110
import io.kubernetes.client.openapi.models.V1Pod;
11+
import oracle.kubernetes.operator.calls.Client;
1212

1313
/** The live implementation of this factory, which uses the 'kubectl exec' command. */
1414
public class KubernetesExecFactoryImpl implements KubernetesExecFactory {
1515
@Override
16-
public KubernetesExec create(ApiClient client, V1Pod pod, String containerName) {
17-
return new KubernetesExecImpl(client, pod, containerName);
16+
public KubernetesExec create(V1Pod pod, String containerName) {
17+
return new KubernetesExecImpl(pod, containerName);
1818
}
1919

2020
public static class KubernetesExecImpl extends KubernetesExec {
21-
private final ApiClient client;
2221
private final V1Pod pod;
2322
private final String containerName;
2423

25-
KubernetesExecImpl(ApiClient client, V1Pod pod, String containerName) {
26-
this.client = client;
24+
KubernetesExecImpl(V1Pod pod, String containerName) {
2725
this.pod = pod;
2826
this.containerName = containerName;
2927
}
3028

3129
@Override
3230
public Process exec(String... command) throws ApiException, IOException {
33-
return new Exec(client).exec(pod, command, containerName, isStdin(), isTty());
31+
return new Exec(Client.getInstance()).exec(pod, command, containerName, isStdin(), isTty());
3432
}
3533
}
3634
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2025, 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;
@@ -10,7 +10,6 @@
1010

1111
import com.meterware.simplestub.Memento;
1212
import com.meterware.simplestub.StaticStubSupport;
13-
import io.kubernetes.client.openapi.ApiClient;
1413
import io.kubernetes.client.openapi.models.V1Pod;
1514
import oracle.kubernetes.operator.helpers.LegalNames;
1615
import oracle.kubernetes.operator.utils.KubernetesExec;
@@ -38,7 +37,7 @@ void defineResponse(String serverName, String response, Integer exitCode) {
3837
}
3938

4039
@Override
41-
public KubernetesExec create(ApiClient client, V1Pod pod, String containerName) {
40+
public KubernetesExec create(V1Pod pod, String containerName) {
4241
return new KubernetesExec() {
4342
@Override
4443
public Process exec(String... command) {

0 commit comments

Comments
 (0)