Skip to content

Commit 6486bd9

Browse files
committed
Added some protective code here and there
1 parent ac0c79a commit 6486bd9

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,16 @@ jobs:
258258
run: mvn --also-make --batch-mode --no-transfer-progress -DskipTests=true -Dmaven.javadoc.skip=true install
259259
- name: Generate Database Name
260260
run: |
261-
# Combine the GitHub Run ID and a random number to guarantee uniqueness
262261
RANDOM_DB="clickhouse_java_test_${GITHUB_RUN_ID}_${RANDOM}"
263-
264-
# Write it to GITHUB_ENV so future steps can access it as $DB_NAME
265262
echo "TEST_DB_NAME=$RANDOM_DB" >> $GITHUB_ENV
266263
echo "Generated database name: $RANDOM_DB"
267-
268264
- name: Create Temporary Database
269265
env:
270266
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT_PROD }}
271267
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT_PROD }}
272268
run: |
273269
echo "Creating database: \`$TEST_DB_NAME\`"
274-
curl -s -u "default:$CLICKHOUSE_CLOUD_PASSWORD" "https://$CLICKHOUSE_CLOUD_HOST:8443" --data-binary "CREATE DATABASE IF NOT EXISTS $TEST_DB_NAME"
270+
curl --fail-with-body -s -u "default:$CLICKHOUSE_CLOUD_PASSWORD" "https://$CLICKHOUSE_CLOUD_HOST:8443" --data-binary "CREATE DATABASE IF NOT EXISTS $TEST_DB_NAME"
275271
- name: Test http client
276272
env:
277273
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT_PROD }}
@@ -298,7 +294,7 @@ jobs:
298294
if [ -n "$TEST_DB_NAME" ]; then
299295
DROP_STMT="DROP DATABASE IF EXISTS \`$TEST_DB_NAME\`"
300296
echo "Cleaning up database: \`$TEST_DB_NAME\` with statement '$DROP_STMT'";
301-
curl -s -u "default:$CLICKHOUSE_CLOUD_PASSWORD" "https://$CLICKHOUSE_CLOUD_HOST:8443" --data-binary "$DROP_STMT";
297+
curl --fail-with-body -s -u "default:$CLICKHOUSE_CLOUD_PASSWORD" "https://$CLICKHOUSE_CLOUD_HOST:8443" --data-binary "$DROP_STMT";
302298
else
303299
echo "No database name was generated; skipping cleanup.";
304300
fi;

clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseServerForTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public class ClickHouseServerForTest {
6868
properties = new Properties(System.getProperties());
6969
String externalDatabase = System.getenv("TEST_DB_NAME"); // see build.yaml workflow
7070
if (externalDatabase != null && !externalDatabase.trim().isEmpty()) {
71+
if (!externalDatabase.startsWith("clickhouse_java_test_")) {
72+
throw new RuntimeException("external database for tests should start with 'clickhouse_java_test_'");
73+
}
7174
localDatabase = false;
7275
database = externalDatabase;
7376
} else {

client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,8 @@ public void testJWTWithCloud() throws Exception {
12201220
}
12211221
final String jwt = System.getenv("CLIENT_JWT");
12221222
final String host = System.getenv("JWT_TEST_HOST");
1223-
Assert.assertTrue(jwt != null && !jwt.trim().isEmpty(), "JWT is missing");
1223+
Assert.assertTrue(jwt != null && !jwt.trim().isEmpty(), "CLIENT_JWT is not set.");
1224+
Assert.assertTrue(host != null && !host.trim().isEmpty(), "JWT_TEST_HOST is not set");
12241225
Assert.assertFalse(jwt.contains("\n") || jwt.contains("-----"), "JWT should be single string ready for HTTP header");
12251226
try (Client client = new Client.Builder()
12261227
.addEndpoint(Protocol.HTTP, host, 8443, true)

0 commit comments

Comments
 (0)