Skip to content

Commit bb523c0

Browse files
authored
Merge pull request #1242 from brendandburns/flake-out
Move away from static wire mocks.
2 parents 5ff0c86 + 73681cf commit bb523c0

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

util/src/test/java/io/kubernetes/client/AttachTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
1717
import static com.github.tomakehurst.wiremock.client.WireMock.get;
1818
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
19-
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2019
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
21-
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
2220
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
2321

2422
import com.github.tomakehurst.wiremock.junit.WireMockRule;
@@ -54,7 +52,7 @@ public void setup() throws IOException {
5452
public void testUrl() throws IOException, ApiException, InterruptedException {
5553
Attach attach = new Attach(client);
5654

57-
stubFor(
55+
wireMockRule.stubFor(
5856
get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/attach"))
5957
.willReturn(
6058
aResponse()
@@ -81,7 +79,7 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
8179
res2.close();
8280
res3.close();
8381

84-
verify(
82+
wireMockRule.verify(
8583
getRequestedFor(
8684
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/attach"))
8785
.withQueryParam("stdin", equalTo("false"))
@@ -90,15 +88,15 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
9088
.withQueryParam("tty", equalTo("false"))
9189
.withQueryParam("container", equalTo(container)));
9290

93-
verify(
91+
wireMockRule.verify(
9492
getRequestedFor(
9593
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/attach"))
9694
.withQueryParam("stdin", equalTo("true"))
9795
.withQueryParam("stdout", equalTo("false"))
9896
.withQueryParam("stderr", equalTo("false"))
9997
.withQueryParam("tty", equalTo("false")));
10098

101-
verify(
99+
wireMockRule.verify(
102100
getRequestedFor(
103101
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/attach"))
104102
.withQueryParam("stdin", equalTo("false"))

util/src/test/java/io/kubernetes/client/DiscoveryTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import static com.github.tomakehurst.wiremock.client.WireMock.get;
1717
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
1818
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
19-
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
2019
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
2120
import static org.junit.Assert.assertEquals;
2221

@@ -59,7 +58,7 @@ public void testDiscoveryRequest() throws ApiException {
5958
.serialize(new V1APIVersions().versions(Arrays.asList("v1", "v2"))))));
6059
Discovery discovery = new Discovery(apiClient);
6160
V1APIVersions versions = discovery.versionDiscovery("/foo");
62-
verify(1, getRequestedFor(urlPathEqualTo("/foo")));
61+
wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/foo")));
6362
assertEquals(2, versions.getVersions().size());
6463
}
6564

util/src/test/java/io/kubernetes/client/ExecTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
1717
import static com.github.tomakehurst.wiremock.client.WireMock.get;
1818
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
19-
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2019
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
21-
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
2220
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
2321
import static org.junit.Assert.assertEquals;
2422

@@ -134,7 +132,7 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
134132

135133
V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(podName).namespace(namespace));
136134

137-
stubFor(
135+
wireMockRule.stubFor(
138136
get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec"))
139137
.willReturn(
140138
aResponse()
@@ -152,7 +150,7 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
152150
.execute()
153151
.waitFor();
154152

155-
verify(
153+
wireMockRule.verify(
156154
getRequestedFor(
157155
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec"))
158156
.withQueryParam("stdin", equalTo("true"))
@@ -162,7 +160,7 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
162160
.withQueryParam("tty", equalTo("false"))
163161
.withQueryParam("command", equalTo("cmd")));
164162

165-
verify(
163+
wireMockRule.verify(
166164
getRequestedFor(
167165
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec"))
168166
.withQueryParam("stdin", equalTo("false"))

util/src/test/java/io/kubernetes/client/PodLogsTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
1717
import static com.github.tomakehurst.wiremock.client.WireMock.get;
1818
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
19-
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2019
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
21-
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
2220
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
2321
import static org.junit.Assert.assertEquals;
2422

@@ -67,7 +65,7 @@ public void testNotFound() throws ApiException, IOException {
6765
new V1PodSpec()
6866
.containers(Arrays.asList(new V1Container().name(container).image("nginx"))));
6967

70-
stubFor(
68+
wireMockRule.stubFor(
7169
get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log"))
7270
.willReturn(
7371
aResponse()
@@ -84,7 +82,7 @@ public void testNotFound() throws ApiException, IOException {
8482
thrown = true;
8583
}
8684
assertEquals(thrown, true);
87-
verify(
85+
wireMockRule.verify(
8886
getRequestedFor(
8987
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log"))
9088
.withQueryParam("container", equalTo(container))
@@ -105,7 +103,7 @@ public void testStream() throws ApiException, IOException {
105103

106104
String content = "this is some\n content for \n various logs \n done";
107105

108-
stubFor(
106+
wireMockRule.stubFor(
109107
get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log"))
110108
.willReturn(
111109
aResponse()
@@ -116,7 +114,7 @@ public void testStream() throws ApiException, IOException {
116114
PodLogs logs = new PodLogs(client);
117115
InputStream is = logs.streamNamespacedPodLog(pod);
118116

119-
verify(
117+
wireMockRule.verify(
120118
getRequestedFor(
121119
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/log"))
122120
.withQueryParam("container", equalTo(container))

util/src/test/java/io/kubernetes/client/PortForwardTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
1717
import static com.github.tomakehurst.wiremock.client.WireMock.get;
1818
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
19-
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2019
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
21-
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
2220
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
2321
import static io.kubernetes.client.ExecTest.makeStream;
2422
import static org.junit.Assert.assertEquals;
@@ -65,7 +63,7 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
6563

6664
V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(podName).namespace(namespace));
6765

68-
stubFor(
66+
wireMockRule.stubFor(
6967
get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/portforward"))
7068
.willReturn(
7169
aResponse()
@@ -87,7 +85,7 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
8785
// event has happened
8886
Thread.sleep(2000);
8987

90-
verify(
88+
wireMockRule.verify(
9189
getRequestedFor(
9290
urlPathEqualTo(
9391
"/api/v1/namespaces/" + namespace + "/pods/" + podName + "/portforward"))

0 commit comments

Comments
 (0)