1
1
package org .testcontainers .containers ;
2
2
3
3
import com .github .dockerjava .api .command .InspectContainerResponse ;
4
- import io .tarantool .driver .api .TarantoolClientBuilder ;
5
4
import org .testcontainers .containers .wait .strategy .Wait ;
6
5
7
6
import java .net .URL ;
8
7
import java .nio .file .Paths ;
9
- import java .util .List ;
10
- import java .util .concurrent .CompletableFuture ;
11
8
import java .util .concurrent .Future ;
12
9
13
10
import static org .testcontainers .containers .PathUtils .normalizePath ;
16
13
* Sets up a Tarantool instance and provides API for configuring it.
17
14
*
18
15
* @author Alexey Kuzin
16
+ * @author Ivan Dneprov
19
17
*/
20
18
public class TarantoolContainer extends GenericContainer <TarantoolContainer >
21
19
implements TarantoolContainerOperations <TarantoolContainer > {
@@ -55,15 +53,6 @@ public TarantoolContainer() {
55
53
this (String .format ("%s:%s" , TARANTOOL_IMAGE , DEFAULT_IMAGE_VERSION ));
56
54
}
57
55
58
- /**
59
- * Constructor for {@link TarantoolContainer}
60
- *
61
- * @param clientBuilder client builder with custom client settings for setting up container
62
- */
63
- public TarantoolContainer (TarantoolClientBuilder clientBuilder ) {
64
- this (String .format ("%s:%s" , TARANTOOL_IMAGE , DEFAULT_IMAGE_VERSION ), clientBuilder );
65
- }
66
-
67
56
/**
68
57
* Constructor for {@link TarantoolContainer}
69
58
*
@@ -74,38 +63,14 @@ public TarantoolContainer(String dockerImageName) {
74
63
clientHelper = new TarantoolContainerClientHelper (this );
75
64
}
76
65
77
- /**
78
- * Constructor for {@link TarantoolContainer}
79
- *
80
- * @param dockerImageName docker image name for container creating
81
- * @param clientBuilder client builder with custom client settings for setting up container
82
- */
83
- public TarantoolContainer (String dockerImageName ,
84
- TarantoolClientBuilder clientBuilder ) {
85
- super (dockerImageName );
86
- clientHelper = new TarantoolContainerClientHelper (this , clientBuilder );
87
- }
88
-
89
66
/**
90
67
* Constructor for {@link TarantoolContainer}
91
68
*
92
69
* @param tarantoolImageParams params for cached image creating
93
70
*/
94
71
public TarantoolContainer (TarantoolImageParams tarantoolImageParams ) {
95
72
super (TarantoolContainerImageHelper .getImage (tarantoolImageParams ));
96
- clientHelper = new TarantoolContainerClientHelper (this );
97
- }
98
-
99
- /**
100
- * Constructor for {@link TarantoolContainer}
101
- *
102
- * @param tarantoolImageParams params for cached image creating
103
- * @param clientBuilder client builder with custom client settings for setting up container
104
- */
105
- public TarantoolContainer (TarantoolImageParams tarantoolImageParams ,
106
- TarantoolClientBuilder clientBuilder ) {
107
- super (TarantoolContainerImageHelper .getImage (tarantoolImageParams ));
108
- clientHelper = new TarantoolContainerClientHelper (this , clientBuilder );
73
+ clientHelper = new TarantoolContainerClientHelper (this , "/sdk/tarantoolctl" );
109
74
}
110
75
111
76
/**
@@ -118,18 +83,6 @@ public TarantoolContainer(Future<String> image) {
118
83
clientHelper = new TarantoolContainerClientHelper (this );
119
84
}
120
85
121
- /**
122
- * Constructor for {@link TarantoolContainer}
123
- *
124
- * @param image future with image name
125
- * @param clientBuilder client builder with custom client settings for setting up container
126
- */
127
- public TarantoolContainer (Future <String > image ,
128
- TarantoolClientBuilder clientBuilder ) {
129
- super (image );
130
- clientHelper = new TarantoolContainerClientHelper (this , clientBuilder );
131
- }
132
-
133
86
/**
134
87
* Use fixed ports binding.
135
88
* Defaults to false.
@@ -223,7 +176,7 @@ public TarantoolContainer withLogLevel(TarantoolLogLevel logLevel) {
223
176
this .logLevel = logLevel ;
224
177
if (isRunning ()) {
225
178
try {
226
- executeCommand (logLevel .toCommand ()). get () ;
179
+ executeCommand (logLevel .toCommand ());
227
180
} catch (Exception e ) {
228
181
logger ().error (String .format ("Failed to set log_level to %s" , logLevel .toString ()), e );
229
182
throw new RuntimeException (e );
@@ -246,7 +199,7 @@ public TarantoolContainer withMemtxMemory(Integer memtxMemory) {
246
199
this .memtxMemory = memtxMemory ;
247
200
if (isRunning ()) {
248
201
try {
249
- executeCommand (String .format ("box.cfg{memtx_memory=%d}" , memtxMemory )). get () ;
202
+ executeCommand (String .format ("box.cfg{memtx_memory=%d}" , memtxMemory ));
250
203
} catch (Exception e ) {
251
204
logger ().error (String .format ("Failed to set memtx_memory to %d" , memtxMemory ), e );
252
205
throw new RuntimeException (e );
@@ -290,6 +243,11 @@ public String getInstanceDir() {
290
243
return instanceDir ;
291
244
}
292
245
246
+ @ Override
247
+ public int getInternalPort () {
248
+ return port ;
249
+ }
250
+
293
251
/**
294
252
* Specify the server init script file name
295
253
*
@@ -380,12 +338,22 @@ protected void containerIsStopping(InspectContainerResponse containerInfo) {
380
338
}
381
339
382
340
@ Override
383
- public CompletableFuture < List <?>> executeScript (String scriptResourcePath ) throws Exception {
341
+ public Container . ExecResult executeScript (String scriptResourcePath ) throws Exception {
384
342
return clientHelper .executeScript (scriptResourcePath );
385
343
}
386
344
387
345
@ Override
388
- public CompletableFuture <List <?>> executeCommand (String command , Object ... arguments ) throws Exception {
389
- return clientHelper .executeCommand (command , arguments );
346
+ public <T > T executeScriptDecoded (String scriptResourcePath ) throws Exception {
347
+ return clientHelper .executeScriptDecoded (scriptResourcePath );
348
+ }
349
+
350
+ @ Override
351
+ public Container .ExecResult executeCommand (String command ) throws Exception {
352
+ return clientHelper .executeCommand (command );
353
+ }
354
+
355
+ @ Override
356
+ public <T > T executeCommandDecoded (String command ) throws Exception {
357
+ return clientHelper .executeCommandDecoded (command );
390
358
}
391
359
}
0 commit comments