Skip to content

Commit f9332af

Browse files
committed
Stabelize tests
1 parent 5be5bdf commit f9332af

7 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/backend/kubernetes/KubernetesBackend.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ private String getInstanceId() throws JsonParseException, JsonMappingException,
457457
if (!file.exists()) {
458458
file = Paths.get(ContainerProxyApplication.CONFIG_DEMO_PROFILE).toFile();
459459
}
460+
if (!file.exists()) {
461+
// this should only happen in tests
462+
instanceId = "unknown-instance-id";
463+
return instanceId;
464+
}
460465

461466
Object parsedConfig = objectMapper.readValue(file, Object.class);
462467
String canonicalConfigFile = objectMapper.writeValueAsString(parsedConfig);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void test1User2Sessions1Spec() throws Exception {
8181
String proxyId2 = loginAndLaunchProxy(user1[0], user1[1], specIds[0]);
8282
doDeleteProxy(proxyId1, user1[0], user1[1]);
8383
doDeleteProxy(proxyId2, user1[0], user1[1]);
84+
Thread.sleep(2000); // delete is handled async -> give time to stop container
8485
}
8586

8687
@Test
@@ -89,6 +90,7 @@ public void test1User2Sessions2Specs() throws Exception {
8990
String proxyId2 = loginAndLaunchProxy(user1[0], user1[1], specIds[1]);
9091
doDeleteProxy(proxyId1, user1[0], user1[1]);
9192
doDeleteProxy(proxyId2, user1[0], user1[1]);
93+
Thread.sleep(2000); // delete is handled async -> give time to stop container
9294
}
9395

9496
@Test
@@ -97,6 +99,7 @@ public void test2Users2Sessions1Spec() throws Exception {
9799
String proxyId2 = loginAndLaunchProxy(user2[0], user2[1], specIds[0]);
98100
doDeleteProxy(proxyId1, user1[0], user1[1]);
99101
doDeleteProxy(proxyId2, user2[0], user2[1]);
102+
Thread.sleep(2000); // delete is handled async -> give time to stop container
100103
}
101104

102105
@Test
@@ -105,6 +108,7 @@ public void test2Users2Sessions2Specs() throws Exception {
105108
String proxyId2 = loginAndLaunchProxy(user2[0], user2[1], specIds[1]);
106109
doDeleteProxy(proxyId1, user1[0], user1[1]);
107110
doDeleteProxy(proxyId2, user2[0], user2[1]);
111+
Thread.sleep(2000); // delete is handled async -> give time to stop container
108112
}
109113

110114
private String loginAndLaunchProxy(String username, String password, String specId) throws Exception {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ 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+
}
400403
client.namespaces().create(new NamespaceBuilder()
401404
.withNewMetadata()
402405
.withName(overridenNamespace)

src/test/resources/application-test-ldap-auth.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
spring:
2+
session:
3+
store-type: none
4+
data:
5+
redis:
6+
repositories:
7+
enabled: false
18
proxy:
29
authentication: ldap
310
ldap:

src/test/resources/application-test-no-auth.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
spring:
2+
session:
3+
store-type: none
4+
data:
5+
redis:
6+
repositories:
7+
enabled: false
18
proxy:
29
authentication: none
310
specs:

src/test/resources/application-test-simple-auth.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
spring:
2+
session:
3+
store-type: none
4+
data:
5+
redis:
6+
repositories:
7+
enabled: false
18
proxy:
29
authentication: simple
310
users:

src/test/resources/application-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
spring:
2+
session:
3+
store-type: none
4+
data:
5+
redis:
6+
repositories:
7+
enabled: false
18
proxy:
29
authentication: simple
310
container-backend: docker
411

12+
513
users:
614
- name: demo
715
password: demo

0 commit comments

Comments
 (0)