-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMultiIntegrationTestBase.java
More file actions
86 lines (76 loc) · 3.42 KB
/
MultiIntegrationTestBase.java
File metadata and controls
86 lines (76 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (c) 2020-2022 - for information on the respective copyright owner
* see the NOTICE file and/or the repository at
* https://github.com/hyperledger-labs/acapy-java-client
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.aries;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@Testcontainers
public abstract class MultiIntegrationTestBase {
private final Logger log = LoggerFactory.getLogger(MultiIntegrationTestBase.class);
public static final String ARIES_VERSION = IntegrationTestBase.ARIES_VERSION;
public static final Integer ARIES_ENDPOINT_PORT = IntegrationTestBase.ARIES_ENDPOINT_PORT;
public static final Integer ARIES_ADMIN_PORT = IntegrationTestBase.ARIES_ADMIN_PORT;
public static final Integer ARIES_ENDPOINT_PORT_2 = 8040;
public static final Integer ARIES_ADMIN_PORT_2 = 8041;
protected LedgerClient lc;
protected AriesClient ac;
protected AriesClient ac2;
Network network = Network.newNetwork();
@Container
protected GenericContainer<?> ariesContainer = new GenericContainer<>(ARIES_VERSION)
.withNetwork(network)
.withNetworkAliases("agent_1")
.withExposedPorts(ARIES_ADMIN_PORT)
.withCommand("start"
+ " -it http 0.0.0.0 " + ARIES_ENDPOINT_PORT
+ " -ot http"
+ " --admin 0.0.0.0 " + ARIES_ADMIN_PORT
+ " --admin-insecure-mode"
+ " --log-level debug"
+ " -e http://agent_1:" + ARIES_ENDPOINT_PORT
+ " --plugin aries_cloudagent.messaging.jsonld"
+ this.extraAgentArgs(1))
.waitingFor(Wait.defaultWaitStrategy())
.withLogConsumer(new Slf4jLogConsumer(log))
;
@Container
protected GenericContainer<?> ariesContainer2 = new GenericContainer<>(ARIES_VERSION)
.withExposedPorts(ARIES_ADMIN_PORT_2)
.withNetwork(network)
.withNetworkAliases("agent_2")
.withCommand("start"
+ " -it http 0.0.0.0 " + ARIES_ENDPOINT_PORT_2
+ " -ot http"
+ " --admin 0.0.0.0 " + ARIES_ADMIN_PORT_2
+ " --admin-insecure-mode"
+ " --log-level debug"
+ " -e http://agent_2:" + ARIES_ENDPOINT_PORT_2
+ " --plugin aries_cloudagent.messaging.jsonld"
+ this.extraAgentArgs(2))
.waitingFor(Wait.defaultWaitStrategy())
.withLogConsumer(new Slf4jLogConsumer(log))
;
protected String extraAgentArgs(int agentNum) {
return " --no-ledger";
}
@BeforeEach
void setup() {
ac = AriesClient.builder()
.url("http://" + ariesContainer.getHost() + ":" + ariesContainer.getMappedPort(ARIES_ADMIN_PORT))
.build();
ac2 = AriesClient.builder()
.url("http://" + ariesContainer2.getHost() + ":" + ariesContainer2.getMappedPort(ARIES_ADMIN_PORT_2))
.build();
}
}