Skip to content

Commit 6954dbd

Browse files
committed
ci: refactor ci test cluster bootstrap
Signed-off-by: iGxnon <[email protected]>
1 parent 9991407 commit 6954dbd

File tree

7 files changed

+114
-129
lines changed

7 files changed

+114
-129
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: gradle/actions/setup-gradle@v3
3939

4040
- name: Start the cluster
41-
run: ./scripts/quick_start.sh
41+
run: docker compose -f ci/docker-compose.yml up -d
4242

4343
- name: Run test
4444
run: ./gradlew test

ci/docker-compose.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
version: '3.9'
2+
3+
networks:
4+
xline_network:
5+
driver: bridge
6+
ipam:
7+
driver: default
8+
config:
9+
- subnet: "172.18.0.0/16"
10+
11+
services:
12+
node1:
13+
image: ghcr.io/xline-kv/xline:latest
14+
networks:
15+
xline_network:
16+
ipv4_address: 172.18.0.2
17+
volumes:
18+
- .:/mnt
19+
ports:
20+
- "2379:2379"
21+
environment:
22+
RUST_LOG: curp=debug,xline=debug
23+
command: >
24+
xline
25+
--name node1
26+
--members node1=http://172.18.0.2:2379,node2=http://172.18.0.3:2379,node3=http://172.18.0.4:2379
27+
--storage-engine rocksdb
28+
--data-dir /usr/local/xline/data-dir
29+
--auth-public-key /mnt/public.pem
30+
--auth-private-key /mnt/private.pem
31+
--is-leader
32+
33+
node2:
34+
image: ghcr.io/xline-kv/xline:latest
35+
networks:
36+
xline_network:
37+
ipv4_address: 172.18.0.3
38+
volumes:
39+
- .:/mnt
40+
ports:
41+
- "2380:2379"
42+
environment:
43+
RUST_LOG: curp=debug,xline=debug
44+
command: >
45+
xline
46+
--name node2
47+
--members node1=http://172.18.0.2:2379,node2=http://172.18.0.3:2379,node3=http://172.18.0.4:2379
48+
--storage-engine rocksdb
49+
--data-dir /usr/local/xline/data-dir
50+
--auth-public-key /mnt/public.pem
51+
--auth-private-key /mnt/private.pem
52+
53+
node3:
54+
image: ghcr.io/xline-kv/xline:latest
55+
networks:
56+
xline_network:
57+
ipv4_address: 172.18.0.4
58+
volumes:
59+
- .:/mnt
60+
ports:
61+
- "2381:2379"
62+
environment:
63+
RUST_LOG: curp=debug,xline=debug
64+
command: >
65+
xline
66+
--name node3
67+
--members node1=http://172.18.0.2:2379,node2=http://172.18.0.3:2379,node3=http://172.18.0.4:2379
68+
--storage-engine rocksdb
69+
--data-dir /usr/local/xline/data-dir
70+
--auth-public-key /mnt/public.pem
71+
--auth-private-key /mnt/private.pem

ci/private.pem

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCnAxxSXJYWZCKr
3+
6f6j0HRUwkhX/0+GXjEclWoLA5+KZAuWMSu8bz6X+IScv4vNwORlGSWOnrz+8mb2
4+
I0F6teVZWfWFqsnyWk7IxM+h9yTg7aY/8685YfWTL7fpWq1/3Fniz4QbsYFuzB1V
5+
gaZ5fD2CSYIKzSD+qVSlXF25JDFHV7b2OdHrX0UKZOTWY/VE//STt+PJKdX9R3pl
6+
kGwAzJIkkcAZy0vhvqT3ASTgXchNeN8wGYYb3YirkqIsQB5Xcs1R1W+yz+IrVa6/
7+
0WMcyE6qtJPZ0lviyT0nHV/pZjXuD4B0aja/1fk/HmXDPMjpK1BuCBTStM/KlcrA
8+
oAxo+YDhAgMBAAECggEAIyJhY+Y8YMuCC753JkklH+ubQn/gX/kSxduc6mJBvuBb
9+
G6aOd97DQT8zzrHxHEDXC3ml0AIO6mdeR6uVC9aWQBzPrOYIA+cBqfTVZVJTvMnh
10+
7pQ6KY01F1izjPDZjQtzEWbseNL30rI3/ZP/zJDZc745EEKlDU3cE8mBogA+Ka6w
11+
GLozT9qQf8knBrtzxH6SvrZpfaRlP95is82b4IuPhqYdG7dVYFTALE1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

ci/public.pem

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApwMcUlyWFmQiq+n+o9B0
3+
VMJIV/9Phl4xHJVqCwOfimQLljErvG8+l/iEnL+LzcDkZRkljp68/vJm9iNBerXl
4+
WVn1harJ8lpOyMTPofck4O2mP/OvOWH1ky+36Vqtf9xZ4s+EG7GBbswdVYGmeXw9
5+
gkmCCs0g/qlUpVxduSQxR1e29jnR619FCmTk1mP1RP/0k7fjySnV/Ud6ZZBsAMyS
6+
JJHAGctL4b6k9wEk4F3ITXjfMBmGG92Iq5KiLEAeV3LNUdVvss/iK1Wuv9FjHMhO
7+
qrST2dJb4sk9Jx1f6WY17g+AdGo2v9X5Px5lwzzI6StQbggU0rTPypXKwKAMaPmA
8+
4QIDAQAB
9+
-----END PUBLIC KEY-----

jxline-core/src/test/java/KVTest.java

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ public class KVTest {
2626
private static final ByteSequence SAMPLE_VALUE_2 = bytesOf("sample_value2");
2727
private static final ByteSequence SAMPLE_KEY_3 = bytesOf("sample_key3");
2828

29+
private static final String INIT_ENDPOINT = "http://127.0.0.1:2379";
30+
2931
@BeforeAll
3032
static void onConnect() {
31-
kvClient = Client.builder().endpoints("http://172.20.0.5:2379").build().getKVClient();
33+
kvClient = Client.builder().endpoints(INIT_ENDPOINT).build().getKVClient();
3234
}
3335

3436
public static ByteSequence bytesOf(final String string) {
@@ -103,30 +105,6 @@ public void testGetWithRev() throws Exception {
103105
.isEqualTo(SAMPLE_VALUE.toString(StandardCharsets.UTF_8));
104106
}
105107

106-
@Test
107-
public void testGetSortedPrefix() throws Exception {
108-
String prefix = randomString();
109-
int numPrefix = 3;
110-
putKeysWithPrefix(prefix, numPrefix);
111-
112-
GetOption option =
113-
GetOption.builder()
114-
.withSortField(GetOption.SortTarget.KEY)
115-
.withSortOrder(GetOption.SortOrder.DESCEND)
116-
.isPrefix(true)
117-
.build();
118-
CompletableFuture<GetResponse> getFeature = kvClient.get(bytesOf(prefix), option);
119-
GetResponse response = getFeature.get();
120-
121-
assertThat(response.getKvs()).hasSize(numPrefix);
122-
for (int i = 0; i < numPrefix; i++) {
123-
assertThat(response.getKvs().get(i).getKey().toString(StandardCharsets.UTF_8))
124-
.isEqualTo(prefix + (numPrefix - i - 1));
125-
assertThat(response.getKvs().get(i).getValue().toString(StandardCharsets.UTF_8))
126-
.isEqualTo(String.valueOf(numPrefix - i - 1));
127-
}
128-
}
129-
130108
@Test
131109
public void testDelete() throws Exception {
132110
// Put content so that we actually have something to delete
@@ -143,34 +121,4 @@ public void testDelete() throws Exception {
143121
DeleteResponse delResp = deleteFuture.get();
144122
assertThat(delResp.getDeleted()).isEqualTo(resp.getKvs().size());
145123
}
146-
147-
@Test
148-
public void testGetAndDeleteWithPrefix() throws Exception {
149-
String prefix = randomString();
150-
ByteSequence key = bytesOf(prefix);
151-
int numPrefixes = 10;
152-
153-
putKeysWithPrefix(prefix, numPrefixes);
154-
155-
// verify get withPrefix.
156-
CompletableFuture<GetResponse> getFuture =
157-
kvClient.get(key, GetOption.builder().isPrefix(true).build());
158-
GetResponse getResp = getFuture.get();
159-
assertThat(getResp.getCount()).isEqualTo(numPrefixes);
160-
161-
// verify del withPrefix.
162-
DeleteOption deleteOpt = DeleteOption.builder().isPrefix(true).build();
163-
CompletableFuture<DeleteResponse> delFuture = kvClient.delete(key, deleteOpt);
164-
DeleteResponse delResp = delFuture.get();
165-
assertThat(delResp.getDeleted()).isEqualTo(numPrefixes);
166-
}
167-
168-
private static void putKeysWithPrefix(String prefix, int numPrefixes)
169-
throws ExecutionException, InterruptedException {
170-
for (int i = 0; i < numPrefixes; i++) {
171-
ByteSequence key = bytesOf(prefix + i);
172-
ByteSequence value = bytesOf("" + i);
173-
kvClient.put(key, value).get();
174-
}
175-
}
176124
}

jxline-core/src/test/java/ProtocolTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
@Timeout(value = 20)
1212
public class ProtocolTest {
13-
static ProtocolClient client;
13+
private static ProtocolClient client;
1414

15-
static String INIT_ENDPOINT = "http://172.20.0.5:2379";
15+
private static final String INIT_ENDPOINT = "http://127.0.0.1:2379";
1616

1717
@BeforeAll
1818
static void onConnect() {

scripts/quick_start.sh

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)