Skip to content

Commit fec6833

Browse files
committed
rename constant. add tests
1 parent d9202bc commit fec6833

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public void run() {
316316
@Override
317317
public void onCompletion(Packet packet) {
318318
AtomicInteger serverHealthRead =
319-
packet.getValue(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ);
319+
packet.getValue(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ);
320320
if (serverHealthRead == null || serverHealthRead.get() == 0) {
321321
loggingFilter.setFiltering(false).resetLogHistory();
322322
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ public interface ProcessingConstants {
3232
public static final String DOMAIN_INTROSPECTOR_LOG_RESULT = "domainIntrospectorLogResult";
3333
public static final String SIT_CONFIG_MAP = "sitConfigMap";
3434

35-
public static final String REMAINING_SERVERS_HEALTH_READ = "serverHealthRead";
35+
public static final String REMAINING_SERVERS_HEALTH_TO_READ = "serverHealthRead";
3636
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public NextAction apply(Packet packet) {
6969
packet.put(SERVER_STATE_MAP, new ConcurrentHashMap<String, String>());
7070
packet.put(SERVER_HEALTH_MAP, new ConcurrentHashMap<String, ServerHealth>());
7171

72-
AtomicInteger serverHealthRead = new AtomicInteger();
73-
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ, serverHealthRead);
72+
AtomicInteger remainingServerHealthToRead = new AtomicInteger();
73+
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ, remainingServerHealthToRead);
7474

7575
Collection<StepAndPacket> startDetails =
7676
info.getServerPods()
@@ -80,7 +80,7 @@ public NextAction apply(Packet packet) {
8080
if (startDetails.isEmpty()) {
8181
return doNext(packet);
8282
} else {
83-
serverHealthRead.set(startDetails.size());
83+
remainingServerHealthToRead.set(startDetails.size());
8484
return doForkJoin(getNext(), packet, startDetails);
8585
}
8686
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ public NextAction apply(Packet packet) {
154154
(ConcurrentMap<String, ServerHealth>)
155155
packet.get(ProcessingConstants.SERVER_HEALTH_MAP);
156156
serverHealthMap.put((String) packet.get(ProcessingConstants.SERVER_NAME), health);
157-
AtomicInteger serverHealthRead =
158-
packet.getValue(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ);
159-
serverHealthRead.getAndDecrement();
157+
AtomicInteger remainingServersHealthToRead =
158+
packet.getValue(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ);
159+
remainingServersHealthToRead.getAndDecrement();
160160
}
161161
}
162162
return doNext(packet);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static oracle.kubernetes.operator.ProcessingConstants.SERVER_STATE_MAP;
1010
import static org.hamcrest.Matchers.contains;
1111
import static org.hamcrest.Matchers.hasEntry;
12+
import static org.hamcrest.Matchers.is;
1213
import static org.hamcrest.junit.MatcherAssert.assertThat;
1314

1415
import com.meterware.pseudoserver.HttpUserAgentTest;
@@ -27,6 +28,7 @@
2728
import java.util.List;
2829
import java.util.Map;
2930
import java.util.Optional;
31+
import java.util.concurrent.atomic.AtomicInteger;
3032
import java.util.function.Function;
3133
import oracle.kubernetes.TestUtils;
3234
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
@@ -119,6 +121,19 @@ public void whenServerPodsReturnNodeManagerStatus_recordInStateMap() {
119121
assertThat(serverStates, hasEntry("server2", "server2 status"));
120122
}
121123

124+
@Test
125+
public void createDomainStatusReaderStep_initializesRemainingServersHealthRead_withNumServers() {
126+
info.setServerPod("server1", createPod("server1"));
127+
info.setServerPod("server2", createPod("server2"));
128+
129+
Packet packet =
130+
testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep));
131+
132+
assertThat(
133+
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ)).get(),
134+
is(2));
135+
}
136+
122137
@SuppressWarnings("unchecked")
123138
private Map<String, String> getServerStates(Packet packet) {
124139
return (Map<String, String>) packet.get(SERVER_STATE_MAP);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ public void withHttpClientStep_logIfMissingHTTPClient() {
9595
final String SERVER_NAME = ADMIN_NAME;
9696
Packet packet =
9797
Stub.createStub(PacketStub.class).withServerName(SERVER_NAME).withGetKeyReturnValue(null);
98-
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ, new AtomicInteger(1));
98+
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ, new AtomicInteger(1));
9999

100100
ReadHealthWithHttpClientStep withHttpClientStep =
101101
new ReadHealthWithHttpClientStep(service, null, next);
102102
withHttpClientStep.apply(packet);
103103

104104
assertThat(logRecords, containsInfo(WLS_HEALTH_READ_FAILED_NO_HTTPCLIENT, SERVER_NAME));
105105
assertThat(
106-
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ)).get(),
106+
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ)).get(),
107107
is(1));
108108
}
109109

@@ -121,14 +121,14 @@ public void withHttpClientStep_decrementRemainingServerHealthReadInPacketIfSucce
121121
.withGetKeyReturnValue(httpClientStub);
122122
packet.put(
123123
ProcessingConstants.SERVER_HEALTH_MAP, new ConcurrentHashMap<String, ServerHealth>());
124-
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ, new AtomicInteger(1));
124+
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ, new AtomicInteger(1));
125125

126126
ReadHealthWithHttpClientStep withHttpClientStep =
127127
new ReadHealthWithHttpClientStep(service, null, next);
128128
withHttpClientStep.apply(packet);
129129

130130
assertThat(
131-
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ)).get(),
131+
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ)).get(),
132132
is(0));
133133
}
134134

@@ -144,7 +144,7 @@ public void withHttpClientStep_decrementRemainingServerHealthReadInMultipleClone
144144
packet.put(HttpClient.KEY, httpClientStub);
145145
packet.put(
146146
ProcessingConstants.SERVER_HEALTH_MAP, new ConcurrentHashMap<String, ServerHealth>());
147-
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ, new AtomicInteger(2));
147+
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ, new AtomicInteger(2));
148148

149149
ReadHealthWithHttpClientStep withHttpClientStep1 =
150150
new ReadHealthWithHttpClientStep(service, null, next);
@@ -160,7 +160,7 @@ public void withHttpClientStep_decrementRemainingServerHealthReadInMultipleClone
160160
withHttpClientStep2.apply(packet2);
161161

162162
assertThat(
163-
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_READ)).get(),
163+
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ)).get(),
164164
is(0));
165165
}
166166

0 commit comments

Comments
 (0)