Skip to content

Commit

Permalink
[#4202] feat(trino-connector): Add addition parameters in TrinoQueryT…
Browse files Browse the repository at this point in the history
…estTool (#4203)

### What changes were proposed in this pull request?

Add addition parameters in TrinoQueryTestTool
You need to passing the arguments like :
--params=key1,value1;key2,value2... on run the TrinoQueryTestTool
### Why are the changes needed?

Fix: #4202 

### Does this PR introduce _any_ user-facing change?

Update the command output and error information of TrinoQueryTestTool

### How was this patch tested?

Manually Test
  • Loading branch information
diqiu50 authored Jul 23, 2024
1 parent f26a6ab commit 7ae4e22
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@
public class TrinoQueryIT extends TrinoQueryITBase {
private static final Logger LOG = LoggerFactory.getLogger(TrinoQueryIT.class);

protected static String testsetsDir = "";
protected AtomicInteger passCount = new AtomicInteger(0);
protected AtomicInteger totalCount = new AtomicInteger(0);
protected static boolean exitOnFailed = true;
static String testsetsDir = "";
AtomicInteger passCount = new AtomicInteger(0);
AtomicInteger totalCount = new AtomicInteger(0);
static boolean exitOnFailed = true;

// key: tester name, value: tester result
private static Map<String, TestStatus> allTestStatus = new TreeMap<>();

private static int testParallelism = 2;

private static Map<String, String> queryParams = new HashMap<>();
static Map<String, String> queryParams = new HashMap<>();

public static Set<String> ciTestsets = new HashSet<>();
static Set<String> ciTestsets = new HashSet<>();

static {
testsetsDir = TrinoQueryIT.class.getClassLoader().getResource("trino-ci-testset").getPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public static void main(String[] args) throws Exception {
options.addOption("tester_id", true, "Specify the tester file name prefix to select to test");
options.addOption("catalog", true, "Specify the catalog name to test");

options.addOption(
"params",
true,
"Additional parameters that can replace the value of ${key} in the testers contents, "
+ "example: --params=key1,v1;key2,v2");

options.addOption("help", false, "Print this help message");

CommandLineParser parser = new PosixParser();
Expand Down Expand Up @@ -113,7 +119,7 @@ public static void main(String[] args) throws Exception {
break;
default:
System.out.println("The value of --auto must be 'all', 'gravitino' or 'none'");
return;
System.exit(1);
}
}

Expand All @@ -139,6 +145,22 @@ public static void main(String[] args) throws Exception {
TrinoQueryIT.postgresqlUri =
Strings.isBlank(postgresqlUri) ? TrinoQueryIT.postgresqlUri : postgresqlUri;

String params = commandLine.getOptionValue("params");
if (Strings.isNotBlank(params)) {
for (String param : params.split(";")) {
String[] split = param.split(",");
String key = split[0].trim();
String value = split[1].trim();
if (Strings.isNotBlank(key) && Strings.isNotBlank(value)) {
TrinoQueryIT.queryParams.put(key, value);
} else {
System.out.println(
"Invalid parameters:" + param + "The format should like --params=key1,v1;key2,v2");
System.exit(1);
}
}
}

String testSet = commandLine.getOptionValue("test_set");
String testerId = commandLine.getOptionValue("tester_id", "");
String catalog = commandLine.getOptionValue("catalog", "");
Expand Down

0 comments on commit 7ae4e22

Please sign in to comment.