forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
253 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2023 Datafuse Labs. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use chrono::TimeZone; | ||
use chrono::Utc; | ||
use databend_common_meta_app as mt; | ||
use databend_common_meta_app::principal::UserPrivilegeType; | ||
use databend_common_meta_app::share::ShareGrantObjectPrivilege; | ||
use enumflags2::make_bitflags; | ||
use minitrace::func_name; | ||
|
||
use crate::common; | ||
|
||
// These bytes are built when a new version in introduced, | ||
// and are kept for backward compatibility test. | ||
// | ||
// ************************************************************* | ||
// * These messages should never be updated, * | ||
// * only be added when a new version is added, * | ||
// * or be removed when an old version is no longer supported. * | ||
// ************************************************************* | ||
// | ||
|
||
#[test] | ||
fn test_decode_v78_grant_entry() -> anyhow::Result<()> { | ||
let grant_entry_v78 = vec![ | ||
10, 8, 10, 0, 160, 6, 78, 168, 6, 24, 16, 254, 255, 55, 160, 6, 78, 168, 6, 24, | ||
]; | ||
|
||
let want = || { | ||
mt::principal::GrantEntry::new( | ||
mt::principal::GrantObject::Global, | ||
make_bitflags!(UserPrivilegeType::{Create | Select | Insert | Update | Delete | Drop | Alter | Super | CreateUser | DropUser | CreateRole | DropRole | Grant | CreateStage | Set | CreateDataMask | Read | Write }), | ||
) | ||
}; | ||
|
||
common::test_pb_from_to(func_name!(), want())?; | ||
common::test_load_old(func_name!(), grant_entry_v78.as_slice(), 78, want())?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_decode_v78_share_grant_entry() -> anyhow::Result<()> { | ||
let share_grant_entry_v78 = vec![ | ||
10, 8, 16, 19, 160, 6, 78, 168, 6, 24, 16, 4, 26, 23, 50, 48, 49, 52, 45, 49, 49, 45, 50, | ||
56, 32, 49, 50, 58, 48, 48, 58, 48, 57, 32, 85, 84, 67, 160, 6, 78, 168, 6, 24, | ||
]; | ||
|
||
let want = || mt::share::ShareGrantEntry { | ||
object: mt::share::ShareGrantObject::Table(19), | ||
privileges: make_bitflags!(ShareGrantObjectPrivilege::{Select}), | ||
grant_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(), | ||
update_on: None, | ||
}; | ||
|
||
common::test_pb_from_to(func_name!(), want())?; | ||
common::test_load_old(func_name!(), share_grant_entry_v78.as_slice(), 78, want())?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
SCRIPT_PATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)" | ||
echo " === SCRIPT_PATH: $SCRIPT_PATH" | ||
# go to work tree root | ||
cd "$SCRIPT_PATH/../../" | ||
ROOT="$(pwd)" | ||
pwd | ||
|
||
export RUST_BACKTRACE=full | ||
|
||
BUILD_PROFILE="${BUILD_PROFILE:-debug}" | ||
|
||
query_config_path="scripts/ci/deploy/config/databend-query-node-1.toml" | ||
|
||
usage() { | ||
echo " === Assert that an old version query being compatible with lastest version query on fuse-table format" | ||
echo " === Expect ./bins/current contains current version binaries" | ||
echo " === Usage: $0 <old_version> <logictest_path> <supplementray_statless_test_path>" | ||
} | ||
|
||
source "${SCRIPT_PATH}/util.sh" | ||
|
||
|
||
# -- main -- | ||
|
||
# The previous version to assert compatibility with | ||
# e.g. old_query_ver="0.7.151" | ||
old_query_ver="$1" | ||
|
||
# default sqllogic test suite is "testlogictest_path=${2:-"./base"}s/fuse-forward-compat/compat-logictest/" | ||
logictest_path=${2:-"./base"} | ||
|
||
# supplementary stateless test suite if provided (optional), which will be searched under "tests/fuse-forward-compat/compat-stateless" | ||
stateless_test_path="$3" | ||
|
||
echo " === old query ver : ${old_query_ver}" | ||
echo " === sql logic test path: ${logictest_path}" | ||
echo " === supplementary stateless test path: ${stateless_test_path}" | ||
|
||
|
||
chmod +x ./bins/current/* | ||
|
||
echo " === current metasrv ver: $(./bins/current/databend-meta --single --cmd ver | tr '\n' ' ')" | ||
echo " === current query ver: $(./bins/current/databend-query --cmd ver | tr '\n' ' ')" | ||
echo " === old query ver: $old_query_ver" | ||
|
||
|
||
mkdir -p ./target/${BUILD_PROFILE}/ | ||
|
||
download_query_config "$old_query_ver" old_config | ||
download_binary "$old_query_ver" | ||
|
||
echo "=== Now test forward compat ===" | ||
|
||
old_config_path="old_config/$query_config_path" | ||
run_test $old_query_ver $old_config_path $logictest_path "forward" | ||
|
||
if [ -n "$stateless_test_path" ]; | ||
then | ||
echo "=== ruing supplementary stateless test: ${stateless_test_path}" | ||
run_stateless $stateless_test_path | ||
fi |
Oops, something went wrong.