File tree Expand file tree Collapse file tree 5 files changed +13
-21
lines changed
plugin/trino-teradata/src/test/java/io/trino/plugin/teradata/integration Expand file tree Collapse file tree 5 files changed +13
-21
lines changed Original file line number Diff line number Diff line change 2121import io .trino .Session ;
2222import io .trino .metadata .QualifiedObjectName ;
2323import io .trino .plugin .teradata .TeradataPlugin ;
24- import io .trino .plugin .teradata .integration .clearscape .ClearScapeEnvironmentUtils ;
2524import io .trino .plugin .tpch .TpchPlugin ;
2625import io .trino .testing .DistributedQueryRunner ;
2726import io .trino .testing .QueryRunner ;
@@ -52,7 +51,7 @@ public static void main(String[] args)
5251 Logging logger = Logging .initialize ();
5352 logger .setLevel ("io.trino.plugin.teradata" , Level .DEBUG );
5453 logger .setLevel ("io.trino" , Level .INFO );
55- TestingTeradataServer server = new TestingTeradataServer (ClearScapeEnvironmentUtils . generateUniqueEnvName ( TeradataQueryRunner . class ) );
54+ TestingTeradataServer server = new TestingTeradataServer (" TeradataQueryRunner" , false );
5655 QueryRunner queryRunner = builder (server ).addCoordinatorProperty ("http-server.http.port" , "8080" ).setInitialTables (TpchTable .getTables ()).build ();
5756
5857 Logger log = Logger .get (TeradataQueryRunner .class );
Original file line number Diff line number Diff line change 1515
1616import io .trino .Session ;
1717import io .trino .plugin .jdbc .BaseJdbcConnectorTest ;
18- import io .trino .plugin .teradata .integration .clearscape .ClearScapeEnvironmentUtils ;
1918import io .trino .sql .query .QueryAssertions ;
2019import io .trino .testing .QueryRunner ;
2120import io .trino .testing .TestingConnectorBehavior ;
3332import java .util .OptionalInt ;
3433import java .util .function .Consumer ;
3534
35+ import static io .trino .plugin .teradata .integration .clearscape .ClearScapeEnvironmentUtils .generateUniqueEnvName ;
3636import static io .trino .testing .TestingNames .randomNameSuffix ;
3737import static java .lang .String .format ;
3838import static java .util .Objects .requireNonNull ;
@@ -65,7 +65,7 @@ protected SqlExecutor onRemoteDatabase()
6565 protected QueryRunner createQueryRunner ()
6666 throws Exception
6767 {
68- database = closeAfterClass (new TestingTeradataServer (ClearScapeEnvironmentUtils . generateUniqueEnvName (getClass ())));
68+ database = closeAfterClass (new TestingTeradataServer (generateUniqueEnvName (getClass ()), true ));
6969 // Register this specific instance for this test class
7070 return TeradataQueryRunner .builder (database ).setInitialTables (REQUIRED_TPCH_TABLES ).build ();
7171 }
Original file line number Diff line number Diff line change 1313 */
1414package io .trino .plugin .teradata .integration ;
1515
16- import io .trino .plugin .teradata .integration .clearscape .ClearScapeEnvironmentUtils ;
1716import io .trino .testing .AbstractTestQueryFramework ;
1817import io .trino .testing .QueryRunner ;
1918import io .trino .testing .datatype .CreateAndInsertDataSetup ;
2322
2423import java .sql .SQLException ;
2524
25+ import static io .trino .plugin .teradata .integration .clearscape .ClearScapeEnvironmentUtils .generateUniqueEnvName ;
2626import static io .trino .spi .type .BigintType .BIGINT ;
2727import static io .trino .spi .type .CharType .createCharType ;
2828import static io .trino .spi .type .DateType .DATE ;
3838final class TestTeradataTypeMapping
3939 extends AbstractTestQueryFramework
4040{
41- private final String envName ;
4241 private TestingTeradataServer database ;
4342
44- public TestTeradataTypeMapping ()
45- {
46- envName = ClearScapeEnvironmentUtils .generateUniqueEnvName (TestTeradataTypeMapping .class );
47- }
48-
4943 @ Override
5044 protected QueryRunner createQueryRunner ()
5145 throws Exception
5246 {
53- database = closeAfterClass (new TestingTeradataServer (envName ));
47+ database = closeAfterClass (new TestingTeradataServer (generateUniqueEnvName ( getClass ()), true ));
5448 // Register this specific instance for this test class
5549 return TeradataQueryRunner .builder (database ).build ();
5650 }
Original file line number Diff line number Diff line change 3030import static io .trino .testing .SystemEnvironmentUtils .isEnvSet ;
3131import static io .trino .testing .SystemEnvironmentUtils .requireEnv ;
3232
33- public class TestingTeradataServer
33+ public final class TestingTeradataServer
3434 implements AutoCloseable , SqlExecutor
3535{
3636 private static final int MAX_RETRIES = 3 ;
@@ -39,13 +39,12 @@ public class TestingTeradataServer
3939 private DatabaseConfig config ;
4040 private ClearScapeSetup clearScapeSetup ;
4141
42- public TestingTeradataServer (String envName )
42+ public TestingTeradataServer (String envName , boolean destroyEnv )
4343 {
4444 config = DatabaseConfigFactory .create (envName );
4545 String hostName = config .getHostName ();
4646 // Initialize ClearScape Instance and Get the host name from ClearScape API in case config is using clearscape
4747 if (config .isUseClearScape ()) {
48- boolean destroyEnv = false ;
4948 if (isEnvSet ("CLEARSCAPE_DESTROY_ENV" )) {
5049 String destroyEnvValue = requireEnv ("CLEARSCAPE_DESTROY_ENV" );
5150 destroyEnv = Boolean .parseBoolean (destroyEnvValue );
Original file line number Diff line number Diff line change 1313 */
1414package io .trino .plugin .teradata .integration .clearscape ;
1515
16+ import java .util .concurrent .ThreadLocalRandom ;
17+
1618import static java .util .Locale .ENGLISH ;
1719
1820public final class ClearScapeEnvironmentUtils
1921{
20- private static final String PREFIX = "trino-test-" ;
21- private static final int MAX_ENV_NAME_LENGTH = 30 ; // Adjust based on ClearScape limits
22+ private static final int MAX_ENV_NAME_LENGTH = 40 ; // Adjust based on ClearScape limits
2223
23- private ClearScapeEnvironmentUtils ()
24- {
25- }
24+ private ClearScapeEnvironmentUtils () {}
2625
2726 public static String generateUniqueEnvName (Class <?> testClass )
2827 {
2928 String className = testClass .getSimpleName ().toLowerCase (ENGLISH );
30- String envName = PREFIX + className ;
29+ String suffix = Long .toString (ThreadLocalRandom .current ().nextLong (Long .MAX_VALUE ), 36 );
30+ String envName = className + "-" + suffix ;
3131 // Truncate if too long
3232 if (envName .length () > MAX_ENV_NAME_LENGTH ) {
3333 envName = envName .substring (0 , MAX_ENV_NAME_LENGTH );
You can’t perform that action at this time.
0 commit comments