|
| 1 | +// Copyright 2023 Datafuse Labs. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +use chrono::DateTime; |
| 16 | +use chrono::Utc; |
| 17 | +use databend_common_meta_app as mt; |
| 18 | +use databend_common_meta_app::principal::UserIdentity; |
| 19 | +use databend_common_meta_app::storage::StorageParams; |
| 20 | +use databend_common_meta_app::storage::StorageWebhdfsConfig; |
| 21 | +use fastrace::func_name; |
| 22 | + |
| 23 | +use crate::common; |
| 24 | + |
| 25 | +// These bytes are built when a new version in introduced, |
| 26 | +// and are kept for backward compatibility test. |
| 27 | +// |
| 28 | +// ************************************************************* |
| 29 | +// * These messages should never be updated, * |
| 30 | +// * only be added when a new version is added, * |
| 31 | +// * or be removed when an old version is no longer supported. * |
| 32 | +// ************************************************************* |
| 33 | +// |
| 34 | +#[test] |
| 35 | +fn test_v117_webhdfs_add_disable_list_batch() -> anyhow::Result<()> { |
| 36 | + // Encoded data of version 117 of databend_common_meta_app::principal::user_stage::StageInfo: |
| 37 | + // It is generated with common::test_pb_from_to(). |
| 38 | + let stage_info_v117 = vec![ |
| 39 | + 10, 22, 119, 101, 98, 104, 100, 102, 115, 58, 47, 47, 100, 105, 114, 47, 116, 111, 47, 102, |
| 40 | + 105, 108, 101, 115, 16, 1, 26, 12, 10, 10, 42, 8, 48, 1, 160, 6, 117, 168, 6, 24, 42, 11, |
| 41 | + 10, 2, 48, 2, 16, 142, 8, 24, 1, 56, 1, 50, 4, 116, 101, 115, 116, 56, 100, 66, 29, 10, 8, |
| 42 | + 100, 97, 116, 97, 98, 101, 110, 100, 18, 11, 100, 97, 116, 97, 98, 101, 110, 100, 46, 114, |
| 43 | + 115, 160, 6, 117, 168, 6, 24, 74, 10, 34, 8, 8, 2, 160, 6, 117, 168, 6, 24, 82, 23, 49, 57, |
| 44 | + 55, 48, 45, 48, 49, 45, 48, 49, 32, 48, 48, 58, 48, 48, 58, 48, 48, 32, 85, 84, 67, 160, 6, |
| 45 | + 117, 168, 6, 24, |
| 46 | + ]; |
| 47 | + |
| 48 | + let want = || mt::principal::StageInfo { |
| 49 | + stage_name: "webhdfs://dir/to/files".to_string(), |
| 50 | + stage_type: mt::principal::StageType::External, |
| 51 | + stage_params: mt::principal::StageParams { |
| 52 | + storage: StorageParams::Webhdfs(StorageWebhdfsConfig { |
| 53 | + disable_list_batch: true, |
| 54 | + ..Default::default() |
| 55 | + }), |
| 56 | + }, |
| 57 | + is_temporary: false, |
| 58 | + file_format_params: mt::principal::FileFormatParams::Json( |
| 59 | + mt::principal::JsonFileFormatParams { |
| 60 | + compression: mt::principal::StageFileCompression::Bz2, |
| 61 | + }, |
| 62 | + ), |
| 63 | + copy_options: mt::principal::CopyOptions { |
| 64 | + on_error: mt::principal::OnErrorMode::AbortNum(2), |
| 65 | + size_limit: 1038, |
| 66 | + max_files: 0, |
| 67 | + split_size: 0, |
| 68 | + purge: true, |
| 69 | + single: false, |
| 70 | + max_file_size: 0, |
| 71 | + disable_variant_check: true, |
| 72 | + return_failed_only: false, |
| 73 | + detailed_output: false, |
| 74 | + }, |
| 75 | + comment: "test".to_string(), |
| 76 | + number_of_files: 100, |
| 77 | + creator: Some(UserIdentity { |
| 78 | + username: "databend".to_string(), |
| 79 | + hostname: "databend.rs".to_string(), |
| 80 | + }), |
| 81 | + created_on: DateTime::<Utc>::default(), |
| 82 | + }; |
| 83 | + |
| 84 | + common::test_pb_from_to(func_name!(), want())?; |
| 85 | + common::test_load_old(func_name!(), stage_info_v117.as_slice(), 117, want())?; |
| 86 | + |
| 87 | + Ok(()) |
| 88 | +} |
0 commit comments