Skip to content

Commit 550105b

Browse files
authored
spotless apply for 81 integ-test files (#327)
add ignore failures for build.gradle. Reverting ignore for checkstyle in integ-test Addressed PR comments. Addressed PR comments to expand jav doc. fixed string formatting Fixed string formatting. Fixed string formatting in MatchPhrasePrefixIT Signed-off-by: Mitchell Gale <[email protected]>
1 parent 245c4f8 commit 550105b

File tree

80 files changed

+7156
-5548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+7156
-5548
lines changed

integ-test/src/test/java/org/opensearch/sql/correctness/CorrectnessIT.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness;
87

98
import static org.opensearch.sql.util.TestUtils.getResourceFilePath;
@@ -32,11 +31,12 @@
3231
import org.opensearch.sql.correctness.testset.TestDataSet;
3332
import org.opensearch.test.OpenSearchIntegTestCase;
3433

35-
/**
36-
* Correctness integration test by performing comparison test with other databases.
37-
*/
34+
/** Correctness integration test by performing comparison test with other databases. */
3835
@OpenSearchIntegTestCase.SuiteScopeTestCase
39-
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE, numDataNodes = 3, supportsDedicatedMasters = false)
36+
@OpenSearchIntegTestCase.ClusterScope(
37+
scope = OpenSearchIntegTestCase.Scope.SUITE,
38+
numDataNodes = 3,
39+
supportsDedicatedMasters = false)
4040
@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
4141
public class CorrectnessIT extends OpenSearchIntegTestCase {
4242

@@ -47,8 +47,8 @@ public void performComparisonTest() throws URISyntaxException {
4747
TestConfig config = new TestConfig(getCmdLineArgs());
4848
LOG.info("Starting comparison test {}", config);
4949

50-
try (ComparisonTest test = new ComparisonTest(getThisDBConnection(config),
51-
getOtherDBConnections(config))) {
50+
try (ComparisonTest test =
51+
new ComparisonTest(getThisDBConnection(config), getOtherDBConnections(config))) {
5252
LOG.info("Loading test data set...");
5353
test.connect();
5454
for (TestDataSet dataSet : config.getTestDataSets()) {
@@ -81,9 +81,7 @@ private DBConnection getThisDBConnection(TestConfig config) throws URISyntaxExce
8181
return new JDBCConnection("DB Tested", dbUrl);
8282
}
8383

84-
/**
85-
* Use OpenSearch cluster given on CLI arg or internal embedded in SQLIntegTestCase
86-
*/
84+
/** Use OpenSearch cluster given on CLI arg or internal embedded in SQLIntegTestCase */
8785
private DBConnection getOpenSearchConnection(TestConfig config) throws URISyntaxException {
8886
RestClient client;
8987
String openSearchHost = config.getOpenSearchHostUrl();
@@ -96,14 +94,11 @@ private DBConnection getOpenSearchConnection(TestConfig config) throws URISyntax
9694
return new OpenSearchConnection("jdbc:opensearch://" + openSearchHost, client);
9795
}
9896

99-
/**
100-
* Create database connection with database name and connect URL
101-
*/
97+
/** Create database connection with database name and connect URL */
10298
private DBConnection[] getOtherDBConnections(TestConfig config) {
103-
return config.getOtherDbConnectionNameAndUrls().
104-
entrySet().stream().
105-
map(e -> new JDBCConnection(e.getKey(), e.getValue())).
106-
toArray(DBConnection[]::new);
99+
return config.getOtherDbConnectionNameAndUrls().entrySet().stream()
100+
.map(e -> new JDBCConnection(e.getKey(), e.getValue()))
101+
.toArray(DBConnection[]::new);
107102
}
108103

109104
private void store(TestReport report) {

integ-test/src/test/java/org/opensearch/sql/correctness/report/ErrorTestCase.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.report;
87

98
import static org.opensearch.sql.correctness.report.TestCaseReport.TestResult.FAILURE;
@@ -12,22 +11,17 @@
1211
import lombok.Getter;
1312
import lombok.ToString;
1413

15-
/**
16-
* Report for test case that ends with an error.
17-
*/
14+
/** Report for test case that ends with an error. */
1815
@EqualsAndHashCode(callSuper = true)
1916
@ToString(callSuper = true)
2017
@Getter
2118
public class ErrorTestCase extends TestCaseReport {
2219

23-
/**
24-
* Root cause of the error
25-
*/
20+
/** Root cause of the error */
2621
private final String reason;
2722

2823
public ErrorTestCase(int id, String sql, String reason) {
2924
super(id, sql, FAILURE);
3025
this.reason = reason;
3126
}
32-
3327
}

integ-test/src/test/java/org/opensearch/sql/correctness/report/FailedTestCase.java

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.report;
87

98
import static org.opensearch.sql.correctness.report.TestCaseReport.TestResult.FAILURE;
@@ -16,41 +15,31 @@
1615
import lombok.ToString;
1716
import org.opensearch.sql.correctness.runner.resultset.DBResult;
1817

19-
/**
20-
* Report for test case that fails due to inconsistent result set.
21-
*/
18+
/** Report for test case that fails due to inconsistent result set. */
2219
@EqualsAndHashCode(callSuper = true)
2320
@ToString(callSuper = true)
2421
@Getter
2522
public class FailedTestCase extends TestCaseReport {
2623

27-
/**
28-
* Inconsistent result sets for reporting
29-
*/
24+
/** Inconsistent result sets for reporting */
3025
private final List<DBResult> resultSets;
3126

32-
/**
33-
* Explain where the difference is caused the test failure.
34-
*/
27+
/** Explain where the difference is caused the test failure. */
3528
private final String explain;
3629

37-
/**
38-
* Errors occurred for partial other databases.
39-
*/
30+
/** Errors occurred for partial other databases. */
4031
private final String errors;
4132

42-
4333
public FailedTestCase(int id, String sql, List<DBResult> resultSets, String errors) {
4434
super(id, sql, FAILURE);
4535
this.resultSets = resultSets;
4636
this.resultSets.sort(Comparator.comparing(DBResult::getDatabaseName));
4737
this.errors = errors;
4838

4939
// Generate explanation by diff the first result with remaining
50-
this.explain = resultSets.subList(1, resultSets.size())
51-
.stream()
52-
.map(result -> resultSets.get(0).diff(result))
53-
.collect(Collectors.joining(", "));
40+
this.explain =
41+
resultSets.subList(1, resultSets.size()).stream()
42+
.map(result -> resultSets.get(0).diff(result))
43+
.collect(Collectors.joining(", "));
5444
}
55-
5645
}

integ-test/src/test/java/org/opensearch/sql/correctness/runner/ComparisonTest.java

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.runner;
87

98
import static com.google.common.collect.ObjectArrays.concat;
@@ -25,24 +24,16 @@
2524
import org.opensearch.sql.correctness.testset.TestQuerySet;
2625
import org.opensearch.sql.legacy.utils.StringUtils;
2726

28-
/**
29-
* Comparison test runner for query result correctness.
30-
*/
27+
/** Comparison test runner for query result correctness. */
3128
public class ComparisonTest implements AutoCloseable {
3229

33-
/**
34-
* Next id for test case
35-
*/
30+
/** Next id for test case */
3631
private int testCaseId = 1;
3732

38-
/**
39-
* Connection for database being tested
40-
*/
33+
/** Connection for database being tested */
4134
private final DBConnection thisConnection;
4235

43-
/**
44-
* Database connections for reference databases
45-
*/
36+
/** Database connections for reference databases */
4637
private final DBConnection[] otherDbConnections;
4738

4839
public ComparisonTest(DBConnection thisConnection, DBConnection[] otherDbConnections) {
@@ -53,9 +44,7 @@ public ComparisonTest(DBConnection thisConnection, DBConnection[] otherDbConnect
5344
Arrays.sort(this.otherDbConnections, Comparator.comparing(DBConnection::getDatabaseName));
5445
}
5546

56-
/**
57-
* Open database connection.
58-
*/
47+
/** Open database connection. */
5948
public void connect() {
6049
for (DBConnection conn : concat(thisConnection, otherDbConnections)) {
6150
conn.connect();
@@ -87,8 +76,11 @@ public TestReport verify(TestQuerySet querySet) {
8776
DBResult openSearchResult = thisConnection.select(sql);
8877
report.addTestCase(compareWithOtherDb(sql, openSearchResult));
8978
} catch (Exception e) {
90-
report.addTestCase(new ErrorTestCase(nextId(), sql,
91-
StringUtils.format("%s: %s", e.getClass().getSimpleName(), extractRootCause(e))));
79+
report.addTestCase(
80+
new ErrorTestCase(
81+
nextId(),
82+
sql,
83+
StringUtils.format("%s: %s", e.getClass().getSimpleName(), extractRootCause(e))));
9284
}
9385
}
9486
return report;
@@ -116,9 +108,7 @@ public void close() {
116108
}
117109
}
118110

119-
/**
120-
* Execute the query and compare with current result
121-
*/
111+
/** Execute the query and compare with current result */
122112
private TestCaseReport compareWithOtherDb(String sql, DBResult openSearchResult) {
123113
List<DBResult> mismatchResults = Lists.newArrayList(openSearchResult);
124114
StringBuilder reasons = new StringBuilder();
@@ -137,7 +127,8 @@ private TestCaseReport compareWithOtherDb(String sql, DBResult openSearchResult)
137127
}
138128
}
139129

140-
if (mismatchResults.size() == 1) { // Only OpenSearch result on list. Cannot find other database support this query
130+
if (mismatchResults.size()
131+
== 1) { // Only OpenSearch result on list. Cannot find other database support this query
141132
return new ErrorTestCase(nextId(), sql, "No other databases support this query: " + reasons);
142133
}
143134
return new FailedTestCase(nextId(), sql, mismatchResults, reasons.toString());
@@ -150,8 +141,8 @@ private int nextId() {
150141
private void insertTestDataInBatch(DBConnection conn, String tableName, List<Object[]> testData) {
151142
Iterator<Object[]> iterator = testData.iterator();
152143
String[] fieldNames = (String[]) iterator.next(); // first row is header of column names
153-
Iterators.partition(iterator, 100).
154-
forEachRemaining(batch -> conn.insert(tableName, fieldNames, batch));
144+
Iterators.partition(iterator, 100)
145+
.forEachRemaining(batch -> conn.insert(tableName, fieldNames, batch));
155146
}
156147

157148
private String extractRootCause(Throwable e) {
@@ -167,5 +158,4 @@ private String extractRootCause(Throwable e) {
167158
}
168159
return e.toString();
169160
}
170-
171161
}

integ-test/src/test/java/org/opensearch/sql/correctness/runner/connection/DBConnection.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,36 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.correctness.runner.connection;
87

98
import java.util.List;
109
import org.opensearch.sql.correctness.runner.resultset.DBResult;
1110

12-
/**
13-
* Abstraction for different databases.
14-
*/
11+
/** Abstraction for different databases. */
1512
public interface DBConnection {
1613

1714
/**
1815
* @return database name
1916
*/
2017
String getDatabaseName();
2118

22-
/**
23-
* Connect to database by opening a connection.
24-
*/
19+
/** Connect to database by opening a connection. */
2520
void connect();
2621

2722
/**
2823
* Create table with the schema.
2924
*
3025
* @param tableName table name
31-
* @param schema schema json in OpenSearch mapping format
26+
* @param schema schema json in OpenSearch mapping format
3227
*/
3328
void create(String tableName, String schema);
3429

3530
/**
3631
* Insert batch of data to database.
3732
*
38-
* @param tableName table name
33+
* @param tableName table name
3934
* @param columnNames column names
40-
* @param batch batch of rows
35+
* @param batch batch of rows
4136
*/
4237
void insert(String tableName, String[] columnNames, List<Object[]> batch);
4338

@@ -56,9 +51,6 @@ public interface DBConnection {
5651
*/
5752
void drop(String tableName);
5853

59-
/**
60-
* Close the database connection.
61-
*/
54+
/** Close the database connection. */
6255
void close();
63-
6456
}

0 commit comments

Comments
 (0)