Skip to content

Commit 73ae39a

Browse files
authored
Merge pull request #2000 from brendandburns/build-matrix
Add Windows to our build matrix.
2 parents 0642e7b + cadf986 commit 73ae39a

File tree

24 files changed

+241
-82
lines changed

24 files changed

+241
-82
lines changed

.github/workflows/maven.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ jobs:
2323
- name: Verify Format and License
2424
run: mvn spotless:check
2525
build:
26-
runs-on: ubuntu-latest
2726
name: Java ${{ matrix.java }} Maven Test
2827
strategy:
2928
matrix:
3029
# Test against the LTS Java versions. TODO: add JDK18 when it becomes available.
3130
java: [ 8.0.x, 11.0.x, 17.0.x ]
31+
os: [ windows-latest, ubuntu-latest ]
32+
runs-on: ${{ matrix.os }}
3233
steps:
3334
- uses: actions/[email protected]
3435
- name: Setup Java
@@ -41,11 +42,9 @@ jobs:
4142
with:
4243
path: ~/.m2/repository
4344
key: ${{ runner.os }}-maven-${{ matrix.java }}-${{ hashFiles('pom.xml', '**/pom.xml') }}
44-
- name: Buid with Maven
45+
- name: Build with Maven
4546
run: |
46-
sudo mvn clean test \
47-
-q \
48-
-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
47+
mvn clean test -q -B --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
4948
build-graalvm:
5049
runs-on: ubuntu-latest
5150
name: GraalVM Maven Test

extended/pom.xml

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,54 @@
113113
<target>8</target>
114114
</configuration>
115115
</plugin>
116-
<plugin>
117-
<groupId>org.apache.maven.plugins</groupId>
118-
<artifactId>maven-surefire-plugin</artifactId>
119-
<configuration>
120-
<argLine>@{argLine} -Xms512m -Xmx1500m</argLine>
121-
<parallel>methods</parallel>
122-
<perCoreThreadCount>false</perCoreThreadCount>
123-
<threadCount>1</threadCount>
124-
<forkCount>1</forkCount>
125-
<reuseForks>false</reuseForks>
126-
</configuration>
127-
</plugin>
128116
</plugins>
129117
</build>
130-
118+
<profiles>
119+
<profile>
120+
<id>surefire-newerJava</id>
121+
<activation>
122+
<jdk>(1.8,)</jdk>
123+
</activation>
124+
<build>
125+
<plugins>
126+
<plugin>
127+
<groupId>org.apache.maven.plugins</groupId>
128+
<artifactId>maven-surefire-plugin</artifactId>
129+
<configuration>
130+
<argLine>
131+
@{argLine} -Xms512m -Xmx1500m --illegal-access=warn --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED
132+
</argLine>
133+
<parallel>methods</parallel>
134+
<perCoreThreadCount>false</perCoreThreadCount>
135+
<threadCount>1</threadCount>
136+
<forkCount>1</forkCount>
137+
<reuseForks>false</reuseForks>
138+
</configuration>
139+
</plugin>
140+
</plugins>
141+
</build>
142+
</profile>
143+
<profile>
144+
<id>surefire-java8</id>
145+
<activation>
146+
<jdk>1.8</jdk>
147+
</activation>
148+
<build>
149+
<plugins>
150+
<plugin>
151+
<groupId>org.apache.maven.plugins</groupId>
152+
<artifactId>maven-surefire-plugin</artifactId>
153+
<configuration>
154+
<argLine>@{argLine} -Xms512m -Xmx1500m</argLine>
155+
<parallel>methods</parallel>
156+
<perCoreThreadCount>false</perCoreThreadCount>
157+
<threadCount>1</threadCount>
158+
<forkCount>1</forkCount>
159+
<reuseForks>false</reuseForks>
160+
</configuration>
161+
</plugin>
162+
</plugins>
163+
</build>
164+
</profile>
165+
</profiles>
131166
</project>

extended/src/main/java/io/kubernetes/client/extended/workqueue/DefaultDelayingQueue.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.concurrent.Executors;
2626
import java.util.concurrent.LinkedBlockingQueue;
2727
import java.util.concurrent.TimeUnit;
28+
import java.util.function.Supplier;
2829

2930
/** The default delaying queue implementation. */
3031
public class DefaultDelayingQueue<T> extends DefaultWorkQueue<T> implements DelayingQueue<T> {
@@ -34,8 +35,10 @@ public class DefaultDelayingQueue<T> extends DefaultWorkQueue<T> implements Dela
3435
private DelayQueue<WaitForEntry<T>> delayQueue;
3536
private ConcurrentMap<T, WaitForEntry<T>> waitingEntryByData;
3637
protected BlockingQueue<WaitForEntry<T>> waitingForAddQueue;
38+
private Supplier<Instant> timeSource;
3739

3840
public DefaultDelayingQueue(ExecutorService waitingWorker) {
41+
this.timeSource = Instant::now;
3942
this.delayQueue = new DelayQueue<>();
4043
this.waitingEntryByData = new ConcurrentHashMap<>();
4144
this.waitingForAddQueue = new LinkedBlockingQueue<>(1000);
@@ -57,10 +60,16 @@ public void addAfter(T item, Duration duration) {
5760
super.add(item);
5861
return;
5962
}
60-
WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now()));
63+
WaitForEntry<T> entry =
64+
new WaitForEntry<>(item, duration.addTo(this.timeSource.get()), this.timeSource);
6165
this.waitingForAddQueue.offer(entry);
6266
}
6367

68+
// Visible for testing
69+
protected void injectTimeSource(Supplier<Instant> fn) {
70+
this.timeSource = fn;
71+
}
72+
6473
private void waitingLoop() {
6574
try {
6675
while (true) {
@@ -78,7 +87,7 @@ private void waitingLoop() {
7887
// a. if ready, remove it from the delay-queue and push it into underlying
7988
// work-queue
8089
// b. if not, refresh the next ready-at time.
81-
Instant now = Instant.now();
90+
Instant now = this.timeSource.get();
8291
if (!Duration.between(entry.readyAtMillis, now).isNegative()) {
8392
delayQueue.remove(entry);
8493
super.add(entry.data);
@@ -92,7 +101,7 @@ private void waitingLoop() {
92101
WaitForEntry<T> waitForEntry =
93102
waitingForAddQueue.poll(nextReadyAt.toMillis(), TimeUnit.MILLISECONDS);
94103
if (waitForEntry != null) {
95-
if (Duration.between(waitForEntry.readyAtMillis, Instant.now()).isNegative()) {
104+
if (Duration.between(waitForEntry.readyAtMillis, this.timeSource.get()).isNegative()) {
96105
// the item is not yet ready, insert it to the delay-queue
97106
insert(this.delayQueue, this.waitingEntryByData, waitForEntry);
98107
} else {
@@ -126,17 +135,19 @@ private void insert(
126135
// WaitForEntry holds the data to add and the time it should be added.
127136
private static class WaitForEntry<T> implements Delayed {
128137

129-
private WaitForEntry(T data, Temporal readyAtMillis) {
138+
private WaitForEntry(T data, Temporal readyAtMillis, Supplier<Instant> timeSource) {
130139
this.data = data;
131140
this.readyAtMillis = readyAtMillis;
141+
this.timeSource = timeSource;
132142
}
133143

134144
private T data;
135145
private Temporal readyAtMillis;
146+
private Supplier<Instant> timeSource;
136147

137148
@Override
138149
public long getDelay(TimeUnit unit) {
139-
Duration duration = Duration.between(Instant.now(), readyAtMillis);
150+
Duration duration = Duration.between(this.timeSource.get(), readyAtMillis);
140151
return unit.convert(duration.toMillis(), TimeUnit.MILLISECONDS);
141152
}
142153

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlApplyTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@
3838
public class KubectlApplyTest {
3939

4040
private static final String DISCOVERY_API =
41-
KubectlApplyTest.class.getClassLoader().getResource("discovery-api.json").getPath();
41+
new java.io.File(
42+
KubectlApplyTest.class.getClassLoader().getResource("discovery-api.json").getPath())
43+
.toString();
4244

4345
private static final String DISCOVERY_APIV1 =
44-
KubectlApplyTest.class.getClassLoader().getResource("discovery-api-v1.json").getPath();
46+
new java.io.File(
47+
KubectlApplyTest.class
48+
.getClassLoader()
49+
.getResource("discovery-api-v1.json")
50+
.getPath())
51+
.toString();
4552

4653
private static final String DISCOVERY_APIS =
47-
KubectlApplyTest.class.getClassLoader().getResource("discovery-apis.json").getPath();
54+
new java.io.File(
55+
KubectlApplyTest.class.getClassLoader().getResource("discovery-apis.json").getPath())
56+
.toString();
4857

4958
private ApiClient apiClient;
5059

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlCreateTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.kubernetes.client.openapi.models.V1ConfigMap;
2222
import io.kubernetes.client.openapi.models.V1ObjectMeta;
2323
import io.kubernetes.client.util.ClientBuilder;
24+
import java.io.File;
2425
import java.io.IOException;
2526
import java.nio.file.Files;
2627
import java.nio.file.Paths;
@@ -32,13 +33,21 @@
3233
public class KubectlCreateTest {
3334

3435
private static final String DISCOVERY_API =
35-
KubectlCreateTest.class.getClassLoader().getResource("discovery-api.json").getPath();
36+
new File(KubectlCreateTest.class.getClassLoader().getResource("discovery-api.json").getPath())
37+
.toString();
3638

3739
private static final String DISCOVERY_APIV1 =
38-
KubectlCreateTest.class.getClassLoader().getResource("discovery-api-v1.json").getPath();
40+
new File(
41+
KubectlCreateTest.class
42+
.getClassLoader()
43+
.getResource("discovery-api-v1.json")
44+
.getPath())
45+
.toString();
3946

4047
private static final String DISCOVERY_APIS =
41-
KubectlCreateTest.class.getClassLoader().getResource("discovery-apis.json").getPath();
48+
new File(
49+
KubectlCreateTest.class.getClassLoader().getResource("discovery-apis.json").getPath())
50+
.toString();
4251

4352
private ApiClient apiClient;
4453

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlDrainTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.kubernetes.client.openapi.models.V1Pod;
3232
import io.kubernetes.client.util.ClientBuilder;
3333
import io.kubernetes.client.util.ModelMapper;
34+
import java.io.File;
3435
import java.io.IOException;
3536
import java.nio.file.Files;
3637
import java.nio.file.Paths;
@@ -41,7 +42,8 @@
4142
public class KubectlDrainTest {
4243

4344
private static final String POD_LIST_API =
44-
KubectlDrainTest.class.getClassLoader().getResource("pod-list.json").getPath();
45+
new File(KubectlDrainTest.class.getClassLoader().getResource("pod-list.json").getPath())
46+
.toString();
4547

4648
private ApiClient apiClient;
4749

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlPatchTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.kubernetes.client.openapi.ApiClient;
2828
import io.kubernetes.client.openapi.models.V1ConfigMap;
2929
import io.kubernetes.client.util.ClientBuilder;
30+
import java.io.File;
3031
import java.io.IOException;
3132
import java.nio.file.Files;
3233
import java.nio.file.Paths;
@@ -37,13 +38,20 @@
3738
public class KubectlPatchTest {
3839

3940
private static final String DISCOVERY_API =
40-
KubectlPatchTest.class.getClassLoader().getResource("discovery-api.json").getPath();
41+
new File(KubectlPatchTest.class.getClassLoader().getResource("discovery-api.json").getPath())
42+
.toString();
4143

4244
private static final String DISCOVERY_APIV1 =
43-
KubectlPatchTest.class.getClassLoader().getResource("discovery-api-v1.json").getPath();
45+
new File(
46+
KubectlPatchTest.class
47+
.getClassLoader()
48+
.getResource("discovery-api-v1.json")
49+
.getPath())
50+
.toString();
4451

4552
private static final String DISCOVERY_APIS =
46-
KubectlPatchTest.class.getClassLoader().getResource("discovery-apis.json").getPath();
53+
new File(KubectlPatchTest.class.getClassLoader().getResource("discovery-apis.json").getPath())
54+
.toString();
4755

4856
private ApiClient apiClient;
4957

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlRolloutTest.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import io.kubernetes.client.openapi.models.V1StatefulSetList;
3535
import io.kubernetes.client.util.ClientBuilder;
3636
import io.kubernetes.client.util.ModelMapper;
37+
import java.io.File;
3738
import java.io.IOException;
3839
import java.nio.file.Files;
3940
import java.nio.file.Paths;
@@ -50,34 +51,56 @@ public class KubectlRolloutTest {
5051
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
5152

5253
private static final String DEPLOYMENT =
53-
KubectlRolloutTest.class.getClassLoader().getResource("deployment.json").getPath();
54+
new File(KubectlRolloutTest.class.getClassLoader().getResource("deployment.json").getPath())
55+
.toString();
5456

5557
private static final String REPLICASET_LIST =
56-
KubectlRolloutTest.class.getClassLoader().getResource("replicaset-list.json").getPath();
58+
new File(
59+
KubectlRolloutTest.class
60+
.getClassLoader()
61+
.getResource("replicaset-list.json")
62+
.getPath())
63+
.toString();
5764

5865
private static final String DAEMON_SET =
59-
KubectlRolloutTest.class.getClassLoader().getResource("daemonset.json").getPath();
66+
new File(KubectlRolloutTest.class.getClassLoader().getResource("daemonset.json").getPath())
67+
.toString();
6068

6169
private static final String PATCHED_DAEMON_SET =
62-
KubectlRolloutTest.class.getClassLoader().getResource("patched-daemonset.json").getPath();
70+
new File(
71+
KubectlRolloutTest.class
72+
.getClassLoader()
73+
.getResource("patched-daemonset.json")
74+
.getPath())
75+
.toString();
6376

6477
private static final String DAEMON_SET_CONTROLLER_REVISION_LIST =
65-
KubectlRolloutTest.class
66-
.getClassLoader()
67-
.getResource("daemonset-controllerrevision-list.json")
68-
.getPath();
78+
new File(
79+
KubectlRolloutTest.class
80+
.getClassLoader()
81+
.getResource("daemonset-controllerrevision-list.json")
82+
.getPath())
83+
.toString();
6984

7085
private static final String STATEFUL_SET =
71-
KubectlRolloutTest.class.getClassLoader().getResource("statefulset.json").getPath();
86+
new File(KubectlRolloutTest.class.getClassLoader().getResource("statefulset.json").getPath())
87+
.toString();
7288

7389
private static final String PATCHED_STATEFUL_SET =
74-
KubectlRolloutTest.class.getClassLoader().getResource("patched-statefulset.json").getPath();
90+
new File(
91+
KubectlRolloutTest.class
92+
.getClassLoader()
93+
.getResource("patched-statefulset.json")
94+
.getPath())
95+
.toString();
7596

7697
private static final String STATEFUL_SET_CONTROLLER_REVISION_LIST =
77-
KubectlRolloutTest.class
78-
.getClassLoader()
79-
.getResource("statefulset-controllerrevision-list.json")
80-
.getPath();
98+
new File(
99+
KubectlRolloutTest.class
100+
.getClassLoader()
101+
.getResource("statefulset-controllerrevision-list.json")
102+
.getPath())
103+
.toString();
81104

82105
@Before
83106
public void setup() throws IOException {

extended/src/test/java/io/kubernetes/client/extended/kubectl/util/deployment/DeploymentHelperTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import io.kubernetes.client.openapi.models.V1ReplicaSet;
2929
import io.kubernetes.client.openapi.models.V1ReplicaSetList;
3030
import io.kubernetes.client.util.ClientBuilder;
31+
import java.io.File;
3132
import java.io.IOException;
3233
import java.nio.file.Files;
3334
import java.nio.file.Paths;
@@ -46,10 +47,16 @@ public class DeploymentHelperTest {
4647
@Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort(), false);
4748

4849
private static final String DEPLOYMENT =
49-
DeploymentHelperTest.class.getClassLoader().getResource("deployment.json").getPath();
50+
new File(DeploymentHelperTest.class.getClassLoader().getResource("deployment.json").getPath())
51+
.toString();
5052

5153
private static final String REPLICASET_LIST =
52-
DeploymentHelperTest.class.getClassLoader().getResource("replicaset-list.json").getPath();
54+
new File(
55+
DeploymentHelperTest.class
56+
.getClassLoader()
57+
.getResource("replicaset-list.json")
58+
.getPath())
59+
.toString();
5360

5461
@Before
5562
public void setup() throws IOException {

0 commit comments

Comments
 (0)