#!/bin/bash # Generates a bunch of directories to be used for testing extension updating related behaviour used in `test/extension/update_extensions_ci.test` # Please consider your energy footprint by only running this script with ccache. # note that subsequent runs used cached artifacts, use `make clean` or rm -rf build/debug to clean set -x set -e DUCKDB_BUILD_DIR="./build/debug" TEST_DIR="./build/extension_metadata_test_data" TEST_DIR_COPY="./build/extension_metadata_test_data_copy" ### Directories to use # Used as the extension installation directory for DuckDB export LOCAL_EXTENSION_DIR="$TEST_DIR/extension_dir" # Repository for testing successfully updating extensions export LOCAL_EXTENSION_REPO_UPDATED="$TEST_DIR/repository" # Repository for testing incorrect platform export LOCAL_EXTENSION_REPO_INCORRECT_PLATFORM="$TEST_DIR/repository_incorrect_platform" # Repository for testing incorrect version export LOCAL_EXTENSION_REPO_INCORRECT_DUCKDB_VERSION="$TEST_DIR/repository_incorrect_version" # Repository where both platform and version mismatch export LOCAL_EXTENSION_REPO_VERSION_AND_PLATFORM_INCORRECT="$TEST_DIR/repository_incorrect_version_and_platform" # Directory containing the extensions for direct installing export DIRECT_INSTALL_DIR="$TEST_DIR/direct_install" # Extension dir with a malformed info file for an extension export LOCAL_EXTENSION_DIR_MALFORMED_INFO="$TEST_DIR/extension_dir_malformed_info" # Extension dir with a metadata install version that mismatches the files metadata export LOCAL_EXTENSION_DIR_INFO_INCORRECT_VERSION="$TEST_DIR/extension_dir_malformed_info_incorrect_version" if [ -d "$TEST_DIR_COPY" ]; then # REUSE PREVIOUSLY GENERATED DATA rm -r $TEST_DIR cp -R $TEST_DIR_COPY $TEST_DIR else # GENERATE FRESH DATA mkdir -p $TEST_DIR mkdir -p $DIRECT_INSTALL_DIR mkdir -p $LOCAL_EXTENSION_DIR mkdir -p $LOCAL_EXTENSION_REPO_UPDATED mkdir -p $LOCAL_EXTENSION_REPO_INCORRECT_PLATFORM mkdir -p $LOCAL_EXTENSION_REPO_INCORRECT_DUCKDB_VERSION ################################################# ### First repo: successfully updating extensions. ################################################# # Set extension config cat > $TEST_DIR/extension_config_before.cmake < $TEST_DIR/extension_config_after.cmake < $TEST_DIR/extension_config_incorrect_platform.cmake < $TEST_DIR/extension_config_incorrect_version.cmake < $TEST_DIR/extension_config_incorrect_version.cmake < $LOCAL_EXTENSION_DIR_MALFORMED_INFO/$DUCKDB_VERSION/$DUCKDB_PLATFORM/tpcds.duckdb_extension.info # Create dir with malformed info file: we install a new version from LOCAL_EXTENSION_REPO_UPDATED but preserve the old info file $DUCKDB_BUILD_DIR/duckdb -unsigned -c "set extension_directory='$LOCAL_EXTENSION_DIR_INFO_INCORRECT_VERSION'; install 'tpch' from '$LOCAL_EXTENSION_REPO_UPDATED'" cp $LOCAL_EXTENSION_DIR/$DUCKDB_VERSION/$DUCKDB_PLATFORM/tpch.duckdb_extension.info $LOCAL_EXTENSION_DIR_INFO_INCORRECT_VERSION/$DUCKDB_VERSION/$DUCKDB_PLATFORM/tpch.duckdb_extension.info ################################################################### ### Allow using copy instead of regenerating test data on every run ################################################################### cp -R $TEST_DIR $TEST_DIR_COPY fi ########################### ### Set version and platform ########################### DUCKDB_VERSION=`$DUCKDB_BUILD_DIR/duckdb -csv -noheader -c 'select source_id from pragma_version()'` DUCKDB_PLATFORM=`cat $DUCKDB_BUILD_DIR/duckdb_platform_out` ########################### ### Populate the minio repositories ########################### AWS_DEFAULT_REGION=eu-west-1 AWS_ACCESS_KEY_ID=minio_duckdb_user AWS_SECRET_ACCESS_KEY=minio_duckdb_user_password aws --endpoint-url http://duckdb-minio.com:9000 s3 sync $LOCAL_EXTENSION_REPO_UPDATED s3://test-bucket-public/ci-test-repo export REMOTE_EXTENSION_REPO_UPDATED=http://duckdb-minio.com:9000/test-bucket-public/ci-test-repo export REMOTE_EXTENSION_REPO_DIRECT_PATH=http://duckdb-minio.com:9000/test-bucket-public/ci-test-repo/$DUCKDB_VERSION/$DUCKDB_PLATFORM ################ ### Run test ################ RUN_EXTENSION_UPDATE_TEST=1 $DUCKDB_BUILD_DIR/test/unittest test/extension/update_extensions_ci.test