Skip to content

Commit

Permalink
cloud: Add an archive sample BigQuery database
Browse files Browse the repository at this point in the history
  • Loading branch information
spbnick committed Feb 7, 2024
1 parent 4250908 commit 44964eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cloud
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,15 @@ function execute_command() {
declare -r bigquery_clean_test_dataset="${prefix}clean_test"
declare -r bigquery_empty_test_dataset="${prefix}empty_test"
declare -r bigquery_kcidb_db="bigquery:${project}.${bigquery_dataset}"
declare -r bigquery_sample_dataset="${prefix}sample"
declare -r bigquery_sample_kcidb_db="bigquery:${project}.${bigquery_sample_dataset}"
declare bigquery_clean_test_kcidb_db="bigquery:${project}."
declare -r bigquery_clean_test_kcidb_db+="${bigquery_clean_test_dataset}"
declare bigquery_empty_test_kcidb_db="bigquery:${project}."
declare -r bigquery_empty_test_kcidb_db+="${bigquery_empty_test_dataset}"
declare -a bigquery_args=("$project" "$bigquery_dataset")
declare -a bigquery_args=(
"$project" "$bigquery_dataset" "$bigquery_sample_dataset"
)
if "$test"; then
bigquery_args+=(
# Do not initialize the clean dataset
Expand All @@ -207,6 +211,8 @@ function execute_command() {
echo -n "$psql_kcidb_db" | escape_whitespace
echo -n " "
echo -n "$bigquery_kcidb_db" | escape_whitespace
echo -n " "
echo -n "$bigquery_sample_kcidb_db" | escape_whitespace
)

if "$test"; then
Expand Down Expand Up @@ -281,6 +287,7 @@ function execute_command() {
--pgpass-secret="$psql_pgpass_secret"
--op-database="$psql_kcidb_db"
--ar-database="$bigquery_kcidb_db"
--sm-database="$bigquery_sample_kcidb_db"
--database="$database"
--clean-test-databases="$clean_test_databases"
--empty-test-databases="$empty_test_databases"
Expand Down
3 changes: 3 additions & 0 deletions kcidb/cloud/cloud_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare _CLOUD_FUNCTIONS_SH=
# --pgpass-secret=NAME
# --op-database=SPEC
# --ar-database=SPEC
# --sm-database=SPEC
# --database=SPEC
# --clean-test-databases=SPEC_LIST
# --empty-test-databases=SPEC_LIST
Expand All @@ -52,6 +53,7 @@ function cloud_functions_env() {
cache_redirector_url \
op_database \
ar_database \
sm_database \
database \
clean_test_databases \
empty_test_databases \
Expand All @@ -69,6 +71,7 @@ function cloud_functions_env() {
[KCIDB_PGPASS_SECRET]="$pgpass_secret"
[KCIDB_OPERATIONAL_DATABASE]="$op_database"
[KCIDB_ARCHIVE_DATABASE]="$ar_database"
[KCIDB_SAMPLE_DATABASE]="$sm_database"
[KCIDB_DATABASE]="$database"
[KCIDB_DATABASE_LOAD_PERIOD_SEC]="180"
[KCIDB_CLEAN_TEST_DATABASES]="$clean_test_databases"
Expand Down
4 changes: 4 additions & 0 deletions kcidb/cloud/scheduler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function scheduler_deploy() {
"$project" "${prefix}purge_op_db_trigger" \
"$purge_db_trigger_topic" '0 6 * * MON' \
'{"database": "op", "timedelta": {"delta": {"months": 6}}}'
scheduler_job_pubsub_deploy \
"$project" "${prefix}purge_sm_db_trigger" \
"$purge_db_trigger_topic" '0 7 * * *' \
'{"database": "sm", "timedelta": {"delta": {"weeks": 4}}}'
}

# Withdraw from the scheduler
Expand Down
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# The specification for the archive database (a part of DATABASE spec)
ARCHIVE_DATABASE = os.environ["KCIDB_ARCHIVE_DATABASE"]

# The specification for the archive sample database (a part of DATABASE spec)
SAMPLE_DATABASE = os.environ["KCIDB_SAMPLE_DATABASE"]

# The specification for the database submissions should be loaded into
DATABASE = os.environ["KCIDB_DATABASE"]

Expand Down Expand Up @@ -435,7 +438,7 @@ def kcidb_purge_db(event, context):
present.
"""
# Accepted databases and their specs
databases = dict(op=OPERATIONAL_DATABASE)
databases = dict(op=OPERATIONAL_DATABASE, sm=SAMPLE_DATABASE)

# Describe the expected event data
schema = dict(
Expand Down

0 comments on commit 44964eb

Please sign in to comment.