Skip to content

Commit a99a3d6

Browse files
committed
Fix Travis + stabilize test more
1 parent da88004 commit a99a3d6

2 files changed

Lines changed: 30 additions & 32 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121

2222
before_install:
2323
- docker pull openanalytics/shinyproxy-demo
24-
- sudo apt-get -qq -y install conntrack
24+
- sudo apt-get -qq -y install conntrack socat
2525

2626
before_script:
2727
# Download kubectl, which is a requirement for using minikube.
@@ -41,5 +41,5 @@ script:
4141
- kubectl cluster-info
4242
# Wait for kube-dns to be ready.
4343
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
44-
- nohup socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock
44+
- nohup socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock &
4545
- mvn test

src/test/java/eu/openanalytics/containerproxy/test/proxy/TestIntegrationOnKube.java

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,7 @@ public void launchProxyWithPodPatches() throws Exception {
397397
final String overridenNamespace = "it-b9fa0a24-overriden";
398398
final String serviceAccountName = "sp-ittest-b9fa0a24-account";
399399
try {
400-
while (client.namespaces().withName(overridenNamespace).get() != null) {
401-
Thread.sleep(1000);
402-
}
403-
client.namespaces().create(new NamespaceBuilder()
404-
.withNewMetadata()
405-
.withName(overridenNamespace)
406-
.endMetadata()
407-
.build());
400+
createOverridenNamespace();
408401

409402
client.serviceAccounts().inNamespace(overridenNamespace).create(new ServiceAccountBuilder()
410403
.withNewMetadata()
@@ -470,12 +463,7 @@ public void launchProxyWithPodPatches() throws Exception {
470463
assertEquals(0, proxyService.getProxies(null, true).size());
471464

472465
} finally {
473-
// just to be sure both the namespace and service account are cleaned up
474-
try {
475-
client.namespaces().withName(overridenNamespace).delete();
476-
} catch(Exception e) {
477-
478-
}
466+
deleteOverridenNamespace();
479467
try {
480468
client.serviceAccounts().withName(serviceAccountName).delete();
481469
} catch(Exception e) {
@@ -542,14 +530,8 @@ public void launchProxyWithPatchesWithMerging() throws Exception {
542530
*/
543531
@Test
544532
public void launchProxyWithAdditionalManifests() throws Exception {
545-
final String overridenNamespace = "it-b9fa0a24-overriden";
546533
try {
547-
System.out.println(client);
548-
client.namespaces().create(new NamespaceBuilder()
549-
.withNewMetadata()
550-
.withName(overridenNamespace)
551-
.endMetadata()
552-
.build());
534+
createOverridenNamespace();
553535

554536
String specId = environment.getProperty("proxy.specs[8].id");
555537

@@ -602,8 +584,7 @@ public void launchProxyWithAdditionalManifests() throws Exception {
602584

603585
assertEquals(0, proxyService.getProxies(null, true).size());
604586
} finally {
605-
// just to be sure both the namespace and service account are cleaned up
606-
client.namespaces().withName(overridenNamespace).delete();
587+
deleteOverridenNamespace();
607588
}
608589
}
609590

@@ -616,14 +597,8 @@ public void launchProxyWithAdditionalManifests() throws Exception {
616597
*/
617598
@Test
618599
public void launchProxyWithAdditionalManifestsOfWhichOneAlreadyExists() throws Exception {
619-
final String overridenNamespace = "it-b9fa0a24-overriden";
620600
try {
621-
System.out.println(client);
622-
client.namespaces().create(new NamespaceBuilder()
623-
.withNewMetadata()
624-
.withName(overridenNamespace)
625-
.endMetadata()
626-
.build());
601+
createOverridenNamespace();
627602

628603
// create the PVC
629604
String pvcSpec =
@@ -693,8 +668,30 @@ public void launchProxyWithAdditionalManifestsOfWhichOneAlreadyExists() throws E
693668

694669
assertEquals(0, proxyService.getProxies(null, true).size());
695670
} finally {
671+
deleteOverridenNamespace();
672+
}
673+
}
674+
675+
private final String overridenNamespace = "it-b9fa0a24-overriden";
676+
677+
private void createOverridenNamespace() throws InterruptedException {
678+
deleteOverridenNamespace();
679+
while (client.namespaces().withName(overridenNamespace).get() != null) {
680+
Thread.sleep(1000);
681+
}
682+
client.namespaces().create(new NamespaceBuilder()
683+
.withNewMetadata()
684+
.withName(overridenNamespace)
685+
.endMetadata()
686+
.build());
687+
}
688+
689+
private void deleteOverridenNamespace() throws InterruptedException {
690+
try {
696691
// just to be sure both the namespace and service account are cleaned up
697692
client.namespaces().withName(overridenNamespace).delete();
693+
} catch (Exception e) {
694+
// ignore
698695
}
699696
}
700697

@@ -748,4 +745,5 @@ public synchronized void removeMapping(String path) {
748745
// No-ops
749746
}
750747
}
748+
751749
}

0 commit comments

Comments
 (0)