mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Add test.
This commit is contained in:
parent
ed942eff76
commit
bd82a2dd97
@ -5,33 +5,38 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
# Copy backups/with_broken_part.zip into the disk named "backups".
|
||||
SRC_BACKUP_DIR=$CURDIR/backups
|
||||
SRC_BACKUP_FILENAME=with_broken_part.zip
|
||||
# Copies a test predefined backup from "/tests/queries/0_stateless/backups/" folder to the "backups" disk,
|
||||
# returns the path to the backup relative to that disk.
|
||||
function install_test_backup()
|
||||
{
|
||||
local test_backup_filename="$1"
|
||||
local test_backup_path="$CURDIR/backups/${test_backup_filename}"
|
||||
|
||||
BACKUPS_DISK=backups
|
||||
BACKUPS_DIR=$($CLICKHOUSE_CLIENT --query "SELECT path FROM system.disks WHERE name='$BACKUPS_DISK'")
|
||||
local backups_disk_root=$($CLICKHOUSE_CLIENT --query "SELECT path FROM system.disks WHERE name='backups'")
|
||||
|
||||
if [ -z "$BACKUPS_DIR" ]; then
|
||||
echo Disk \'$BACKUPS_DISK\' not found
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${backups_disk_root}" ]; then
|
||||
echo Disk \'${backups_disk_root}\' not found
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BACKUP_FILENAME=$CLICKHOUSE_DATABASE/${SRC_BACKUP_FILENAME}
|
||||
BACKUP_NAME="Disk('$BACKUPS_DISK', '$BACKUP_FILENAME')"
|
||||
local install_path=${backups_disk_root}/${CLICKHOUSE_DATABASE}/${test_backup_filename}
|
||||
mkdir -p "$(dirname "${install_path}")"
|
||||
ln -s "${test_backup_path}" "${install_path}"
|
||||
|
||||
mkdir -p "$(dirname "$BACKUPS_DIR/$BACKUP_FILENAME")"
|
||||
ln -s "$SRC_BACKUP_DIR/$SRC_BACKUP_FILENAME" "$BACKUPS_DIR/$BACKUP_FILENAME"
|
||||
echo "${CLICKHOUSE_DATABASE}/${test_backup_filename}"
|
||||
}
|
||||
|
||||
backup_name="$(install_test_backup with_broken_part.zip)"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS tbl"
|
||||
|
||||
# First try to restore with the setting `restore_broken_parts_as_detached` set to false.
|
||||
$CLICKHOUSE_CLIENT --query "RESTORE TABLE default.tbl AS tbl FROM $BACKUP_NAME" 2>&1 | tr -d \\n | grep "data.bin doesn't exist" | grep "while restoring part all_2_2_0" > /dev/null && echo "OK" || echo "FAILED"
|
||||
$CLICKHOUSE_CLIENT --query "RESTORE TABLE default.tbl AS tbl FROM Disk('backups', '${backup_name}')" 2>&1 | tr -d \\n | grep "data.bin doesn't exist" | grep "while restoring part all_2_2_0" > /dev/null && echo "OK" || echo "FAILED"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS tbl"
|
||||
|
||||
# Then try to restore with the setting `restore_broken_parts_as_detached` set to true.
|
||||
$CLICKHOUSE_CLIENT --query "RESTORE TABLE default.tbl AS tbl FROM $BACKUP_NAME SETTINGS restore_broken_parts_as_detached = true" 2>/dev/null | awk -F '\t' '{print $2}'
|
||||
$CLICKHOUSE_CLIENT --query "RESTORE TABLE default.tbl AS tbl FROM Disk('backups', '${backup_name}') SETTINGS restore_broken_parts_as_detached = true" 2>/dev/null | awk -F '\t' '{print $2}'
|
||||
|
||||
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
||||
SELECT * FROM tbl ORDER BY x;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-ordinary-database, no-replicated-database
|
||||
# Tag no-ordinary-database: TO DO
|
||||
# Tags: no-replicated-database
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
|
@ -0,0 +1,4 @@
|
||||
RESTORED
|
||||
2024-02-22 07:00:00 00
|
||||
2024-02-22 07:00:01 11
|
||||
2024-02-22 07:00:02 22
|
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
# Copies a test predefined backup from "/tests/queries/0_stateless/backups/" folder to the "backups" disk,
|
||||
# returns the path to the backup relative to that disk.
|
||||
function install_test_backup()
|
||||
{
|
||||
local test_backup_filename="$1"
|
||||
local test_backup_path="$CURDIR/backups/${test_backup_filename}"
|
||||
|
||||
local backups_disk_root=$($CLICKHOUSE_CLIENT --query "SELECT path FROM system.disks WHERE name='backups'")
|
||||
|
||||
if [ -z "${backups_disk_root}" ]; then
|
||||
echo Disk \'${backups_disk_root}\' not found
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local install_path=${backups_disk_root}/${CLICKHOUSE_DATABASE}/${test_backup_filename}
|
||||
mkdir -p "$(dirname "${install_path}")"
|
||||
ln -s "${test_backup_path}" "${install_path}"
|
||||
|
||||
echo "${CLICKHOUSE_DATABASE}/${test_backup_filename}"
|
||||
}
|
||||
|
||||
backup_name="$(install_test_backup old_backup_with_matview_inner_table_metadata.zip)"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS mv"
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS src"
|
||||
|
||||
db="$CLICKHOUSE_DATABASE"
|
||||
${CLICKHOUSE_CLIENT} -q "RESTORE DATABASE mydb AS ${db} FROM Disk('backups', '${backup_name}') SETTINGS allow_different_database_def=true" | grep -o "RESTORED"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT toDateTime(timestamp, 'UTC') AS ts, c12 FROM mv ORDER BY ts"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE mv"
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE src"
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user