@@ -54,6 +54,12 @@ public class TarantoolCartridgeContainer extends GenericContainer<TarantoolCartr
5454 protected static final int TIMEOUT_ROUTER_UP_CARTRIDGE_HEALTH_IN_SECONDS = 60 ;
5555
5656 private static final String TMP_DIR = "/tmp" ;
57+ private static final String TARANTOOL_VERSION =
58+ System .getenv ().getOrDefault ("TARANTOOL_VERSION" , "2.11.8-ubuntu20.04" );
59+ private static final boolean IS_TARANTOOL2 = TARANTOOL_VERSION .startsWith ("2." );
60+ private static final String TT_COMMAND = IS_TARANTOOL2 ? "tarantoolctl" : "tt" ;
61+ private static final String ECHO_COMMAND_TEMPLATE =
62+ "echo \" %s\" | %s connect %s:%s@127.0.0.1:%d" ;
5763
5864 /**
5965 * Runs a Lua command inside the container by connecting via net.box and returns YAML-encoded
@@ -662,8 +668,20 @@ public ExecResult executeCommand(String command) {
662668 throw new IllegalStateException ("Cannot execute commands in stopped container" );
663669 }
664670 command = command .replace ("\" " , "\\ \" " ).replace ("\' " , "\\ \' " );
665- String bashCommand =
666- String .format (COMMAND_TEMPLATE , routerPort , routerUsername , routerPassword , command );
671+ String bashCommand ;
672+ if (IS_TARANTOOL2 ) {
673+ bashCommand =
674+ String .format (COMMAND_TEMPLATE , routerPort , routerUsername , routerPassword , command );
675+ } else {
676+ bashCommand =
677+ String .format (
678+ ECHO_COMMAND_TEMPLATE ,
679+ command ,
680+ TT_COMMAND ,
681+ routerUsername ,
682+ routerPassword ,
683+ routerPort );
684+ }
667685 return execInContainer ("sh" , "-c" , bashCommand );
668686 } catch (IOException | InterruptedException e ) {
669687 throw new RuntimeException (e );
0 commit comments