Skip to content

Commit

Permalink
Fixing integration test cases (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvmittal10 authored and criccomini committed Oct 22, 2019
1 parent 0ef9879 commit e37bbb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.cloud.bigquery.BigQuery;

import com.wepay.kafka.connect.bigquery.BigQueryHelper;
import com.wepay.kafka.connect.bigquery.utils.FieldNameSanitizer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -44,10 +45,14 @@ public static void main(String[] args) {
}
BigQuery bigQuery = new BigQueryHelper().setKeySource(keySource).connect(args[1], args[0]);
for (int i = tablesStart; i < args.length; i++) {
if (bigQuery.delete(args[2], args[i])) {
logger.info("Table {} in dataset {} deleted successfully", args[i], args[2]);
// May be consider using sanitizeTopics property value in future to decide table name
// sanitization but as currently we always run test cases with sanitizeTopics value as true
// hence sanitize table name prior delete. This is required else it makes test cases flaky.
String table = FieldNameSanitizer.sanitizeName(args[i]);
if (bigQuery.delete(args[2], table)) {
logger.info("Table {} in dataset {} deleted successfully", table, args[2]);
} else {
logger.info("Table {} in dataset {} does not exist", args[i], args[2]);
logger.info("Table {} in dataset {} does not exist", table, args[2]);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions kcbq-connector/test/integrationtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ warn 'Deleting existing BigQuery test tables and existing GCS bucket'
test_tables=
test_topics=
for file in "$BASE_DIR"/resources/test_schemas/*; do
test_tables+="${test_tables:+ }$(basename "kcbq_test_${file/-/_}")"
test_topics+="${test_topics:+,}$(basename "kcbq_test_$file")"
test_tables+="${test_tables:+ }kcbq_test_$(basename "${file/-/_}")"
test_topics+="${test_topics:+,}kcbq_test_$(basename "$file")"
done

"$GRADLEW" -p "$BASE_DIR/.." \
-Pkcbq_test_keyfile="$KCBQ_TEST_KEYFILE" \
-Pkcbq_test_project="$KCBQ_TEST_PROJECT" \
-Pkcbq_test_dataset="$KCBQ_TEST_DATASET" \
-Pkcbq_test_tables="test_tables" \
-Pkcbq_test_tables="$test_tables" \
-Pkcbq_test_bucket="$KCBQ_TEST_BUCKET" \
-Pkcbq_test_keysource="$KCBQ_TEST_KEYSOURCE" \
integrationTestPrep
Expand Down

0 comments on commit e37bbb0

Please sign in to comment.