Skip to content

Commit 862ca06

Browse files
committed
Fixes for unit tests
1 parent 7a826a0 commit 862ca06

File tree

7 files changed

+28
-21
lines changed

7 files changed

+28
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class Main {
107107
static {
108108
container.getComponents().put(
109109
ProcessingConstants.MAIN_COMPONENT_NAME,
110-
Component.createFor(tuningAndConfig, callBuilderFactory, CallBuilderFactory.class));
110+
Component.createFor(tuningAndConfig, callBuilderFactory));
111111
}
112112

113113
private static final ConcurrentMap<String, Boolean> initialized = new ConcurrentHashMap<>();

src/main/java/oracle/kubernetes/operator/helpers/CallBuilderFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public CallBuilderFactory(TuningParameters tuning) {
1313
}
1414

1515
public CallBuilder create() {
16-
return CallBuilder.create(tuning.getCallBuilderTuning());
16+
return CallBuilder.create(tuning != null ? tuning.getCallBuilderTuning() : null);
1717
}
1818
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import oracle.kubernetes.operator.helpers.HealthCheckHelper;
1212
import oracle.kubernetes.operator.logging.LoggingFacade;
1313
import oracle.kubernetes.operator.logging.LoggingFactory;
14+
import oracle.kubernetes.operator.work.Component;
1415
import oracle.kubernetes.operator.work.ContainerResolver;
1516

1617
import org.junit.After;
@@ -62,7 +63,10 @@ public void tearDown() throws Exception {
6263
@Test
6364
@Ignore
6465
public void testDefaultNamespace() throws Exception {
65-
66+
ContainerResolver.getInstance().getContainer().getComponents().put(
67+
ProcessingConstants.MAIN_COMPONENT_NAME,
68+
Component.createFor(new CallBuilderFactory(null)));
69+
6670
defaultHealthCheckHelper.performSecurityChecks("default");
6771
hdlr.flush();
6872
String logOutput = bos.toString();
@@ -79,6 +83,10 @@ public void testDefaultNamespace() throws Exception {
7983
@Ignore
8084
// TODO work out why this test is failing - it is a rbac issue, need to trace where it is coming from
8185
public void testUnitTestNamespace() throws Exception {
86+
ContainerResolver.getInstance().getContainer().getComponents().put(
87+
ProcessingConstants.MAIN_COMPONENT_NAME,
88+
Component.createFor(new CallBuilderFactory(null)));
89+
8290
unitHealthCheckHelper.performSecurityChecks("weblogic-operator-account");
8391
hdlr.flush();
8492
String logOutput = bos.toString();
@@ -95,6 +103,11 @@ public void testUnitTestNamespace() throws Exception {
95103
@Test
96104
public void testAccountNoPrivs() throws Exception {
97105
Assume.assumeTrue(TestUtils.isKubernetesAvailable());
106+
107+
ContainerResolver.getInstance().getContainer().getComponents().put(
108+
ProcessingConstants.MAIN_COMPONENT_NAME,
109+
Component.createFor(new CallBuilderFactory(null)));
110+
98111
unitHealthCheckHelper.performSecurityChecks("unit-test-svc-account-no-privs");
99112
hdlr.flush();
100113
String logOutput = bos.toString();
@@ -106,7 +119,7 @@ public void testAccountNoPrivs() throws Exception {
106119

107120
// Create a named namespace
108121
private V1Namespace createNamespace(String name) throws Exception {
109-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
122+
CallBuilderFactory factory = new CallBuilderFactory(null);
110123
try {
111124
V1Namespace existing = factory.create().readNamespace(name);
112125
if (existing != null)

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
import io.kubernetes.client.models.V1Secret;
1111
import io.kubernetes.client.models.V1Status;
1212
import io.kubernetes.client.models.VersionInfo;
13-
import oracle.kubernetes.operator.helpers.CallBuilder;
1413
import oracle.kubernetes.operator.helpers.CallBuilderFactory;
15-
import oracle.kubernetes.operator.helpers.ClientPool;
1614
import oracle.kubernetes.operator.helpers.SecretHelper;
17-
import oracle.kubernetes.operator.work.ContainerResolver;
1815

1916
import org.junit.After;
2017
import org.junit.Assert;
@@ -41,7 +38,7 @@ public class SecretHelperTest {
4138

4239
@Before
4340
public void setUp() throws Exception {
44-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
41+
CallBuilderFactory factory = new CallBuilderFactory(null);
4542
// Determine if 1.8 since some bugs with kubernetes-client / java and secrets
4643
VersionInfo verInfo = factory.create().readVersionCode();
4744
if ("1".equals(verInfo.getMajor()) && "8".equals(verInfo.getMinor())) {
@@ -141,7 +138,7 @@ public void testUnitTestNamespace() throws Exception {
141138
// Create a named secret with username / password in specified name
142139
private V1Secret createSecret(String name, String namespace) throws Exception {
143140

144-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
141+
CallBuilderFactory factory = new CallBuilderFactory(null);
145142
try {
146143
V1Secret existing = factory.create().readSecret(name, namespace);
147144
if (existing != null)
@@ -181,7 +178,7 @@ private V1Secret createSecret(String name, String namespace) throws Exception {
181178
// Create a named secret with no username / password in specified namespace
182179
private V1Secret createInvalidSecret(String name, String namespace) throws Exception {
183180

184-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
181+
CallBuilderFactory factory = new CallBuilderFactory(null);
185182
try {
186183
V1Secret existing = factory.create().readSecret(name, namespace);
187184
if (existing != null)
@@ -214,14 +211,14 @@ private V1Status deleteSecret(String name, String namespace) throws Exception {
214211
if (isVersion18)
215212
return null;
216213

217-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
214+
CallBuilderFactory factory = new CallBuilderFactory(null);
218215
return factory.create().deleteSecret(name, namespace, new V1DeleteOptions());
219216
}
220217

221218
// Create a named namespace
222219
private V1Namespace createNamespace(String name) throws Exception {
223220

224-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
221+
CallBuilderFactory factory = new CallBuilderFactory(null);
225222
try {
226223
V1Namespace existing = factory.create().readNamespace(name);
227224
if (existing != null)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
1616
import oracle.kubernetes.operator.helpers.ServiceHelper;
1717
import oracle.kubernetes.operator.work.Component;
18-
import oracle.kubernetes.operator.work.ContainerResolver;
1918
import oracle.kubernetes.operator.work.Engine;
2019
import oracle.kubernetes.operator.work.Fiber;
2120
import oracle.kubernetes.operator.work.Packet;
@@ -39,7 +38,7 @@ public class ServiceHelperTest {
3938

4039
@Before
4140
public void startClean() throws Exception {
42-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
41+
CallBuilderFactory factory = new CallBuilderFactory(null);
4342

4443
// Delete the service if left around.
4544
System.out.println("Deleting service pre-test");
@@ -55,7 +54,7 @@ public void startClean() throws Exception {
5554

5655
@After
5756
public void tearDown() throws Exception {
58-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
57+
CallBuilderFactory factory = new CallBuilderFactory(null);
5958

6059
// Delete the service if we created one.
6160
if (serviceCreated) {
@@ -67,7 +66,7 @@ public void tearDown() throws Exception {
6766

6867
@Test
6968
public void createReadListUpdate() throws Exception {
70-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
69+
CallBuilderFactory factory = new CallBuilderFactory(null);
7170

7271
// Domain
7372
Domain dom = new Domain();

src/test/java/oracle/kubernetes/operator/helpers/CallBuilderTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import io.kubernetes.client.ApiException;
2121
import oracle.kubernetes.weblogic.domain.v1.DomainList;
22-
import oracle.kubernetes.operator.work.ContainerResolver;
2322
import oracle.kubernetes.operator.work.Engine;
2423
import oracle.kubernetes.operator.work.Packet;
2524
import oracle.kubernetes.operator.work.Step;
@@ -81,7 +80,7 @@ public SetupStep(Step next) {
8180
public NextAction apply(Packet packet) {
8281
String namespace = "default";
8382

84-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
83+
CallBuilderFactory factory = new CallBuilderFactory(null);
8584
Step list = factory.create().listDomainAsync(namespace, new ResponseStep<DomainList>(null) {
8685

8786
@SuppressWarnings("unchecked")

src/test/java/oracle/kubernetes/operator/helpers/IngressHelperTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import oracle.kubernetes.operator.wlsconfig.WlsDomainConfig;
2323
import oracle.kubernetes.operator.wlsconfig.WlsServerConfig;
2424
import oracle.kubernetes.operator.work.Component;
25-
import oracle.kubernetes.operator.work.ContainerResolver;
2625
import oracle.kubernetes.operator.work.Engine;
2726
import oracle.kubernetes.operator.work.Fiber;
2827
import oracle.kubernetes.operator.work.Fiber.CompletionCallback;
@@ -128,7 +127,7 @@ public void setUp() throws ApiException {
128127

129128
@After
130129
public void tearDown() throws ApiException {
131-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
130+
CallBuilderFactory factory = new CallBuilderFactory(null);
132131
try {
133132
factory.create().deleteIngress(ingressName, namespace, new V1DeleteOptions());
134133
} catch (ApiException api) {
@@ -166,7 +165,7 @@ public void onThrowable(Packet packet, Throwable throwable) {
166165
}
167166

168167
// Now check
169-
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
168+
CallBuilderFactory factory = new CallBuilderFactory(null);
170169
V1beta1Ingress v1beta1Ingress = factory.create().readIngress(ingressName, namespace);
171170

172171
List<V1beta1HTTPIngressPath> v1beta1HTTPIngressPaths = getPathArray(v1beta1Ingress);

0 commit comments

Comments
 (0)