8585public class TarantoolCartridgeContainer extends GenericContainer <TarantoolCartridgeContainer >
8686 implements TarantoolContainerOperations <TarantoolCartridgeContainer > {
8787
88- private static final String ROUTER_HOST = "localhost" ;
89- private static final int ROUTER_PORT = 3301 ;
90- private static final String CARTRIDGE_USERNAME = "admin" ;
91- private static final String CARTRIDGE_PASSWORD = "testapp-cluster-cookie" ;
92- private static final String DOCKERFILE = "Dockerfile" ;
93- private static final int API_PORT = 8081 ;
94- private static final String VSHARD_BOOTSTRAP_COMMAND = "return require('cartridge').admin_bootstrap_vshard()" ;
95- private static final String SCRIPT_RESOURCE_DIRECTORY = "" ;
96- private static final String INSTANCE_DIR = "/app" ;
97-
98- private static final String ENV_TARANTOOL_VERSION = "TARANTOOL_VERSION" ;
99- private static final String ENV_TARANTOOL_SERVER_USER = "TARANTOOL_SERVER_USER" ;
100- private static final String ENV_TARANTOOL_SERVER_UID = "TARANTOOL_SERVER_UID" ;
101- private static final String ENV_TARANTOOL_SERVER_GROUP = "TARANTOOL_SERVER_GROUP" ;
102- private static final String ENV_TARANTOOL_SERVER_GID = "TARANTOOL_SERVER_GID" ;
103- private static final String ENV_TARANTOOL_WORKDIR = "TARANTOOL_WORKDIR" ;
104- private static final String ENV_TARANTOOL_RUNDIR = "TARANTOOL_RUNDIR" ;
105- private static final String ENV_TARANTOOL_LOGDIR = "TARANTOOL_LOGDIR" ;
106- private static final String ENV_TARANTOOL_DATADIR = "TARANTOOL_DATADIR" ;
107- private static final String ENV_TARANTOOL_INSTANCES_FILE = "TARANTOOL_INSTANCES_FILE" ;
108- private static final String ENV_TARANTOOL_CLUSTER_COOKIE = "TARANTOOL_CLUSTER_COOKIE" ;
109- private static final String healthyCmd = "return require('cartridge').is_healthy()" ;
110- private static final int TWO_MINUTES = 120 ;
111-
112- private final CartridgeConfigParser instanceFileParser ;
113- private final TarantoolContainerClientHelper clientHelper ;
114- private final String TARANTOOL_RUN_DIR ;
115-
116- private boolean useFixedPorts = false ;
117- private String routerHost = ROUTER_HOST ;
118- private int routerPort = ROUTER_PORT ;
119- private int apiPort = API_PORT ;
120- private String routerUsername = CARTRIDGE_USERNAME ;
121- private String routerPassword = CARTRIDGE_PASSWORD ;
122- private String directoryResourcePath = SCRIPT_RESOURCE_DIRECTORY ;
123- private String instanceDir = INSTANCE_DIR ;
124- private String topologyConfigurationFile ;
125- private String instancesFile ;
126- private SslContext sslContext ;
88+ protected static final String ROUTER_HOST = "localhost" ;
89+ protected static final int ROUTER_PORT = 3301 ;
90+ protected static final String CARTRIDGE_USERNAME = "admin" ;
91+ protected static final String CARTRIDGE_PASSWORD = "testapp-cluster-cookie" ;
92+ protected static final String DOCKERFILE = "Dockerfile" ;
93+ protected static final int API_PORT = 8081 ;
94+ protected static final String VSHARD_BOOTSTRAP_COMMAND = "return require('cartridge').admin_bootstrap_vshard()" ;
95+ protected static final String SCRIPT_RESOURCE_DIRECTORY = "" ;
96+ protected static final String INSTANCE_DIR = "/app" ;
97+
98+ public static final String ENV_TARANTOOL_VERSION = "TARANTOOL_VERSION" ;
99+ public static final String ENV_TARANTOOL_SERVER_USER = "TARANTOOL_SERVER_USER" ;
100+ public static final String ENV_TARANTOOL_SERVER_UID = "TARANTOOL_SERVER_UID" ;
101+ public static final String ENV_TARANTOOL_SERVER_GROUP = "TARANTOOL_SERVER_GROUP" ;
102+ public static final String ENV_TARANTOOL_SERVER_GID = "TARANTOOL_SERVER_GID" ;
103+ public static final String ENV_TARANTOOL_WORKDIR = "TARANTOOL_WORKDIR" ;
104+ public static final String ENV_TARANTOOL_RUNDIR = "TARANTOOL_RUNDIR" ;
105+ public static final String ENV_TARANTOOL_LOGDIR = "TARANTOOL_LOGDIR" ;
106+ public static final String ENV_TARANTOOL_DATADIR = "TARANTOOL_DATADIR" ;
107+ public static final String ENV_TARANTOOL_INSTANCES_FILE = "TARANTOOL_INSTANCES_FILE" ;
108+ public static final String ENV_TARANTOOL_CLUSTER_COOKIE = "TARANTOOL_CLUSTER_COOKIE" ;
109+ protected static final String healthyCmd = "return require('cartridge').is_healthy()" ;
110+ protected static final int TWO_MINUTES = 120 ;
111+
112+ protected final CartridgeConfigParser instanceFileParser ;
113+ protected final TarantoolContainerClientHelper clientHelper ;
114+ protected final String TARANTOOL_RUN_DIR ;
115+
116+ protected boolean useFixedPorts = false ;
117+ protected String routerHost = ROUTER_HOST ;
118+ protected int routerPort = ROUTER_PORT ;
119+ protected int apiPort = API_PORT ;
120+ protected String routerUsername = CARTRIDGE_USERNAME ;
121+ protected String routerPassword = CARTRIDGE_PASSWORD ;
122+ protected String directoryResourcePath = SCRIPT_RESOURCE_DIRECTORY ;
123+ protected String instanceDir = INSTANCE_DIR ;
124+ protected String topologyConfigurationFile ;
125+ protected String instancesFile ;
126+ protected SslContext sslContext ;
127127
128128 /**
129129 * Create a container with default image and specified instances file from the classpath resources. Assumes that
@@ -195,7 +195,7 @@ public TarantoolCartridgeContainer(String dockerFile, String buildImageName, Str
195195 this (buildImage (dockerFile , buildImageName , buildArgs ), instancesFile , topologyConfigurationFile , buildArgs );
196196 }
197197
198- private TarantoolCartridgeContainer (ImageFromDockerfile image , String instancesFile ,
198+ protected TarantoolCartridgeContainer (ImageFromDockerfile image , String instancesFile ,
199199 String topologyConfigurationFile ,
200200 Map <String , String > buildArgs ) {
201201 super (withBuildArgs (image , buildArgs ));
@@ -214,7 +214,7 @@ private TarantoolCartridgeContainer(ImageFromDockerfile image, String instancesF
214214 this .clientHelper = new TarantoolContainerClientHelper (this );
215215 }
216216
217- private static ImageFromDockerfile withBuildArgs (ImageFromDockerfile image , Map <String , String > buildArgs ) {
217+ protected static ImageFromDockerfile withBuildArgs (ImageFromDockerfile image , Map <String , String > buildArgs ) {
218218 Map <String , String > args = mergeBuildArguments (buildArgs );
219219
220220 if (!args .isEmpty ()) {
@@ -234,7 +234,7 @@ public TarantoolCartridgeContainer withExposedPort(Integer port) {
234234 return this ;
235235 }
236236
237- private static Map <String , String > mergeBuildArguments (Map <String , String > buildArgs ) {
237+ protected static Map <String , String > mergeBuildArguments (Map <String , String > buildArgs ) {
238238 Map <String , String > args = new HashMap <>(buildArgs );
239239
240240 for (String envVariable : Arrays .asList (
@@ -258,7 +258,7 @@ private static Map<String, String> mergeBuildArguments(Map<String, String> build
258258 return args ;
259259 }
260260
261- private static ImageFromDockerfile buildImage (String dockerFile , String buildImageName ,
261+ protected static ImageFromDockerfile buildImage (String dockerFile , String buildImageName ,
262262 final Map <String , String > buildArgs ) {
263263 ImageFromDockerfile image ;
264264 if (buildImageName != null && !buildImageName .isEmpty ()) {
@@ -497,7 +497,7 @@ protected void containerIsStarting(InspectContainerResponse containerInfo) {
497497 logger ().info ("Tarantool Cartridge cluster is starting" );
498498 }
499499
500- private boolean setupTopology () {
500+ protected boolean setupTopology () {
501501 String fileType = topologyConfigurationFile
502502 .substring (topologyConfigurationFile .lastIndexOf ('.' ) + 1 );
503503 if (fileType .equals ("yml" )) {
@@ -546,7 +546,7 @@ private boolean setupTopology() {
546546 return true ;
547547 }
548548
549- private void retryingSetupTopology () {
549+ protected void retryingSetupTopology () {
550550 if (!setupTopology ()) {
551551 try {
552552 logger ().info ("Retrying setup topology in 10 seconds" );
@@ -560,7 +560,7 @@ private void retryingSetupTopology() {
560560 }
561561 }
562562
563- private void bootstrapVshard () {
563+ protected void bootstrapVshard () {
564564 try {
565565 executeCommand (VSHARD_BOOTSTRAP_COMMAND );
566566 } catch (Exception e ) {
@@ -584,21 +584,21 @@ protected void containerIsStarted(InspectContainerResponse containerInfo, boolea
584584 logger ().info ("Tarantool Cartridge HTTP API is available at {}:{}" , getAPIHost (), getAPIPort ());
585585 }
586586
587- private void waitUntilRouterIsUp (int secondsToWait ) {
587+ protected void waitUntilRouterIsUp (int secondsToWait ) {
588588 if (!waitUntilTrue (secondsToWait , this ::routerIsUp )) {
589589 throw new RuntimeException ("Timeout exceeded during router starting stage." +
590590 " See the specific error in logs." );
591591 }
592592 }
593593
594- private void waitUntilCartridgeIsHealthy (int secondsToWait ) {
594+ protected void waitUntilCartridgeIsHealthy (int secondsToWait ) {
595595 if (!waitUntilTrue (secondsToWait , this ::isCartridgeHealthy )) {
596596 throw new RuntimeException ("Timeout exceeded during cartridge topology applying stage." +
597597 " See the specific error in logs." );
598598 }
599599 }
600600
601- private boolean waitUntilTrue (int secondsToWait , Supplier <Boolean > waitFunc ) {
601+ protected boolean waitUntilTrue (int secondsToWait , Supplier <Boolean > waitFunc ) {
602602 int secondsPassed = 0 ;
603603 boolean result = waitFunc .get ();
604604 while (!result && secondsPassed < secondsToWait ) {
@@ -613,7 +613,7 @@ private boolean waitUntilTrue(int secondsToWait, Supplier<Boolean> waitFunc) {
613613 return result ;
614614 }
615615
616- private boolean routerIsUp () {
616+ protected boolean routerIsUp () {
617617 ExecResult result ;
618618 try {
619619 result = executeCommand (healthyCmd );
@@ -634,7 +634,7 @@ private boolean routerIsUp() {
634634
635635 }
636636
637- private boolean isCartridgeHealthy () {
637+ protected boolean isCartridgeHealthy () {
638638 ExecResult result ;
639639 try {
640640 result = executeCommand (healthyCmd );
0 commit comments