-
Notifications
You must be signed in to change notification settings - Fork 13
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
10 changed files
with
512 additions
and
17 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
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
36 changes: 36 additions & 0 deletions
36
src/e2e/app/cli/inmem/tests/tests/commands/test_compact_command.rs
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,36 @@ | ||
// Copyright Kamu Data, Inc. and contributors. All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
use kamu_cli_e2e_common::prelude::*; | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
kamu_cli_execute_command_e2e_test!( | ||
storage = inmem, | ||
fixture = kamu_cli_e2e_repo_tests::test_compact_hard | ||
extra_test_groups = "engine, ingest, datafusion" | ||
); | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
kamu_cli_execute_command_e2e_test!( | ||
storage = inmem, | ||
fixture = kamu_cli_e2e_repo_tests::test_compact_keep_metadata_only | ||
extra_test_groups = "engine, ingest, datafusion" | ||
); | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
kamu_cli_execute_command_e2e_test!( | ||
storage = inmem, | ||
fixture = kamu_cli_e2e_repo_tests::test_compact_verify | ||
extra_test_groups = "engine, ingest, datafusion" | ||
); | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
36 changes: 36 additions & 0 deletions
36
src/e2e/app/cli/inmem/tests/tests/commands/test_verify_command.rs
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,36 @@ | ||
// Copyright Kamu Data, Inc. and contributors. All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
use kamu_cli_e2e_common::prelude::*; | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
kamu_cli_execute_command_e2e_test!( | ||
storage = inmem, | ||
fixture = kamu_cli_e2e_repo_tests::test_verify_regular_dataset | ||
extra_test_groups = "engine, ingest, datafusion" | ||
); | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
kamu_cli_execute_command_e2e_test!( | ||
storage = inmem, | ||
fixture = kamu_cli_e2e_repo_tests::test_verify_recursive | ||
extra_test_groups = "containerized, engine, ingest, datafusion" | ||
); | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
kamu_cli_execute_command_e2e_test!( | ||
storage = inmem, | ||
fixture = kamu_cli_e2e_repo_tests::test_verify_integrity | ||
extra_test_groups = "engine, ingest, datafusion" | ||
); | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
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
208 changes: 208 additions & 0 deletions
208
src/e2e/app/cli/repo-tests/src/commands/test_compact_command.rs
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,208 @@ | ||
// Copyright Kamu Data, Inc. and contributors. All rights reserved. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the LICENSE file. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
use std::assert_matches::assert_matches; | ||
|
||
use kamu_cli_e2e_common::DATASET_ROOT_PLAYER_SCORES_SNAPSHOT_STR; | ||
use kamu_cli_puppet::extensions::KamuCliPuppetExt; | ||
use kamu_cli_puppet::KamuCliPuppet; | ||
use opendatafabric::{DatasetName, MetadataEvent}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
pub async fn test_compact_hard(kamu: KamuCliPuppet) { | ||
let dataset_name = DatasetName::new_unchecked("player-scores"); | ||
|
||
kamu.execute_with_input(["add", "--stdin"], DATASET_ROOT_PLAYER_SCORES_SNAPSHOT_STR) | ||
.await | ||
.success(); | ||
|
||
let data = indoc::indoc!( | ||
r#" | ||
{"match_time": "2000-01-01", "match_id": 2, "player_id": "Bob", "score": 90} | ||
"#, | ||
); | ||
|
||
kamu.ingest_data(&dataset_name, data).await; | ||
let data = indoc::indoc!( | ||
r#" | ||
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Alice", "score": 90} | ||
"#, | ||
); | ||
|
||
kamu.ingest_data(&dataset_name, data).await; | ||
|
||
let blocks_before_compacting = kamu.list_blocks(&dataset_name).await; | ||
|
||
let assert = kamu | ||
.execute([ | ||
"--yes", | ||
"system", | ||
"compact", | ||
dataset_name.as_str(), | ||
"--hard", | ||
]) | ||
.await | ||
.success(); | ||
|
||
let stderr = std::str::from_utf8(&assert.get_output().stderr).unwrap(); | ||
|
||
assert!( | ||
stderr.contains(indoc::indoc!( | ||
r#" | ||
1 dataset(s) were compacted | ||
"# | ||
)), | ||
"Unexpected output:\n{stderr}", | ||
); | ||
|
||
let blocks_after_compacting = kamu.list_blocks(&dataset_name).await; | ||
assert_eq!( | ||
blocks_before_compacting.len() - 1, | ||
blocks_after_compacting.len() | ||
); | ||
assert_matches!( | ||
blocks_after_compacting.first().unwrap().block.event, | ||
MetadataEvent::AddData(_) | ||
); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
pub async fn test_compact_keep_metadata_only(kamu: KamuCliPuppet) { | ||
let dataset_name = DatasetName::new_unchecked("player-scores"); | ||
|
||
kamu.execute_with_input(["add", "--stdin"], DATASET_ROOT_PLAYER_SCORES_SNAPSHOT_STR) | ||
.await | ||
.success(); | ||
|
||
let data = indoc::indoc!( | ||
r#" | ||
{"match_time": "2000-01-01", "match_id": 2, "player_id": "Bob", "score": 90} | ||
"#, | ||
); | ||
|
||
kamu.ingest_data(&dataset_name, data).await; | ||
let data = indoc::indoc!( | ||
r#" | ||
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Alice", "score": 90} | ||
"#, | ||
); | ||
|
||
kamu.ingest_data(&dataset_name, data).await; | ||
|
||
let blocks_before_compacting = kamu.list_blocks(&dataset_name).await; | ||
|
||
let assert = kamu | ||
.execute([ | ||
"--yes", | ||
"system", | ||
"compact", | ||
dataset_name.as_str(), | ||
"--hard", | ||
"--keep-metadata-only", | ||
]) | ||
.await | ||
.success(); | ||
|
||
let stderr = std::str::from_utf8(&assert.get_output().stderr).unwrap(); | ||
|
||
assert!( | ||
stderr.contains(indoc::indoc!( | ||
r#" | ||
1 dataset(s) were compacted | ||
"# | ||
)), | ||
"Unexpected output:\n{stderr}", | ||
); | ||
|
||
let blocks_after_compacting = kamu.list_blocks(&dataset_name).await; | ||
assert_eq!( | ||
blocks_before_compacting.len() - 2, | ||
blocks_after_compacting.len() | ||
); | ||
assert_matches!( | ||
blocks_after_compacting.first().unwrap().block.event, | ||
MetadataEvent::SetDataSchema(_) | ||
); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
pub async fn test_compact_verify(kamu: KamuCliPuppet) { | ||
let dataset_name = DatasetName::new_unchecked("player-scores"); | ||
|
||
kamu.execute_with_input(["add", "--stdin"], DATASET_ROOT_PLAYER_SCORES_SNAPSHOT_STR) | ||
.await | ||
.success(); | ||
|
||
let data = indoc::indoc!( | ||
r#" | ||
{"match_time": "2000-01-01", "match_id": 2, "player_id": "Bob", "score": 90} | ||
"#, | ||
); | ||
|
||
kamu.ingest_data(&dataset_name, data).await; | ||
let data = indoc::indoc!( | ||
r#" | ||
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Alice", "score": 90} | ||
"#, | ||
); | ||
|
||
kamu.ingest_data(&dataset_name, data).await; | ||
|
||
let blocks_before_compacting = kamu.list_blocks(&dataset_name).await; | ||
|
||
let assert = kamu | ||
.execute([ | ||
"--yes", | ||
"system", | ||
"compact", | ||
dataset_name.as_str(), | ||
"--hard", | ||
"--verify", | ||
]) | ||
.await | ||
.success(); | ||
|
||
let stderr = std::str::from_utf8(&assert.get_output().stderr).unwrap(); | ||
|
||
assert!( | ||
stderr.contains( | ||
indoc::indoc!( | ||
r#" | ||
verify with dataset_ref: player-scores | ||
"# | ||
) | ||
.trim() | ||
), | ||
"Unexpected output:\n{stderr}", | ||
); | ||
|
||
assert!( | ||
stderr.contains(indoc::indoc!( | ||
r#" | ||
1 dataset(s) were compacted | ||
"# | ||
)), | ||
"Unexpected output:\n{stderr}", | ||
); | ||
|
||
let blocks_after_compacting = kamu.list_blocks(&dataset_name).await; | ||
assert_eq!( | ||
blocks_before_compacting.len() - 1, | ||
blocks_after_compacting.len() | ||
); | ||
assert_matches!( | ||
blocks_after_compacting.first().unwrap().block.event, | ||
MetadataEvent::AddData(_) | ||
); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Oops, something went wrong.