Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: add (or expand) config/init/add/rename command tests #878

Merged
merged 22 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0166a06
KamuCliApiServerHarnessOptions::with_kamu_config(): introduce
s373r Oct 7, 2024
bafac0f
E2E: cover "kamu config" command
s373r Oct 7, 2024
45c9c70
E2E, test_init_in_an_existing_workspace(): add
s373r Oct 7, 2024
ecad943
E2E, test_config_set_value(): respect potential CI agent podman confi…
s373r Oct 7, 2024
b37f272
Updated yanked crate: futures-channel
s373r Oct 7, 2024
09ee92b
E2E, test_config_get_with_default(): respect potential CI agent podma…
s373r Oct 7, 2024
be18047
kamu-cli-e2e-common: extract "player-scores" & "leaderboard" datasets…
s373r Oct 7, 2024
d5986be
assert_cmd: add patch
s373r Oct 7, 2024
2e5bb02
E2E, test_add_dataset_from_stdin(): add
s373r Oct 7, 2024
3697237
E2E, test_add_dataset_from_stdin(): add
s373r Oct 7, 2024
0a241a2
AddCommand::validate_args(): fix "name" arg processing
s373r Oct 7, 2024
48b1af9
E2E, test_add_dataset_with_name(): mix add commands
s373r Oct 7, 2024
0962e9c
E2E, test_add_dataset_with_replace(): add
s373r Oct 7, 2024
400db69
Interact: fix if is_tty
s373r Oct 7, 2024
1a3799b
CHANGELOG.md: update
s373r Oct 7, 2024
d602f79
E2E, test_delete_dataset(): add
s373r Oct 7, 2024
9c16d30
E2E, test_delete_dataset_recursive(): add
s373r Oct 7, 2024
614f316
E2E, test_delete_dataset_all(): add
s373r Oct 7, 2024
af366a7
E2E, test_rename_dataset(): add
s373r Oct 7, 2024
e883060
assert_cmd: use patch (now from the kamu-data org)
s373r Oct 7, 2024
65f5785
kamu-cli-puppet: remove unused dep
s373r Oct 8, 2024
b589eff
Extracted to the separate PR
s373r Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Recommendation: for ease of reading, use the following order:
## [Unreleased]
### Added
- Postgres implementation for dataset entry and account Re-BAC repositories
- Added (or expanded) E2E tests for:
- `kamu config` command
- `kamu init` command
- `kamu add` command
- `kamu rename` command
### Changed
- `kamu repo alias list`: added JSON output alongside with other formats mentioned in the command's help
- Private Datasets, `DatasetEntry` integration that will allow us to build dataset indexing
Expand Down
33 changes: 17 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,4 @@ debug = "line-tables-only"
# datafusion-odata = { git = 'https://github.com/kamu-data/datafusion-odata.git', branch = '42.0.0-axum-0.6' }
# datafusion-ethers = { git = "https://github.com/kamu-data/datafusion-ethers.git", tag = "42.0.0" }
# object_store = { git = 'https://github.com/s373r/arrow-rs', branch = 'add-debug-logs', package = "object_store" }
assert_cmd = { git = 'https://github.com/kamu-data/assert_cmd', branch = "deactivate-output-truncation" }
3 changes: 2 additions & 1 deletion src/app/cli/src/commands/add_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ impl Command for AddCommand {
"No manifest references or paths were provided",
));
}
if self.name.is_some() && (self.recursive || self.snapshot_refs.len() != 1) {
if self.name.is_some() && (self.recursive || !(self.snapshot_refs.len() == 1 || self.stdin))
{
return Err(CLIError::usage_error(
"Name override can be used only when adding a single manifest",
));
Expand Down
20 changes: 14 additions & 6 deletions src/app/cli/src/output/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

use crate::CLIError;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#[derive(Debug, Clone)]
pub struct Interact {
/// Don't ask user for confirmation and assume 'yes'
Expand All @@ -26,17 +28,21 @@ impl Interact {
pub fn require_confirmation(&self, prompt: impl std::fmt::Display) -> Result<(), CLIError> {
use read_input::prelude::*;

// If there's confirmation, we don't need to ask anything of the user
if self.assume_yes {
return Ok(());
}

let prompt = format!("{prompt}\nDo you wish to continue? [y/N]: ");

// If no data can be entered, we abort
if !self.is_tty {
return if self.assume_yes {
Ok(())
} else {
eprintln!("{prompt} Assuming 'no' because --yes flag was not provided");
Err(CLIError::Aborted)
};
eprintln!("{prompt} Assuming 'no' because --yes flag was not provided");

return Err(CLIError::Aborted);
}

// In other cases, we ask until we get a valid answer
let answer: String = input()
.repeat_msg(prompt)
.default("n".to_owned())
Expand All @@ -50,3 +56,5 @@ impl Interact {
}
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 changes: 2 additions & 0 deletions src/app/cli/src/services/config/config_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ impl ConfigService {

fn path_for_scope(&self, scope: ConfigScope) -> PathBuf {
match scope {
// TODO: Respect `XDG_CONFIG_HOME` when working with configs
// https://github.com/kamu-data/kamu-cli/issues/848
ConfigScope::User => dirs::home_dir()
.expect("Cannot determine user home directory")
.join(CONFIG_FILENAME),
Expand Down
1 change: 1 addition & 0 deletions src/e2e/app/cli/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ opendatafabric = { workspace = true }
async-trait = "0.1"
chrono = { version = "0.4", default-features = false, features = ["now"] }
indoc = "2"
lazy_static = { version = "1" }
pretty_assertions = "1"
regex = "1"
reqwest = { version = "0.12", default-features = false, features = ["json"] }
Expand Down
33 changes: 25 additions & 8 deletions src/e2e/app/cli/common/src/e2e_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct KamuCliApiServerHarnessOptions {
potential_workspace: PotentialWorkspace,
env_vars: Vec<(String, String)>,
frozen_system_time: Option<DateTime<Utc>>,
kamu_config: Option<String>,
}

impl KamuCliApiServerHarnessOptions {
Expand Down Expand Up @@ -70,13 +71,18 @@ impl KamuCliApiServerHarnessOptions {

self.with_frozen_system_time(today)
}

pub fn with_kamu_config(mut self, content: &str) -> Self {
self.kamu_config = Some(content.into());

self
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

pub struct KamuCliApiServerHarness {
options: KamuCliApiServerHarnessOptions,
kamu_config: Option<String>,
}

impl KamuCliApiServerHarness {
Expand Down Expand Up @@ -174,11 +180,21 @@ impl KamuCliApiServerHarness {
Self::new(options, Some(kamu_config))
}

fn new(options: KamuCliApiServerHarnessOptions, kamu_config: Option<String>) -> Self {
Self {
options,
kamu_config,
fn new(
mut options: KamuCliApiServerHarnessOptions,
generated_kamu_config: Option<String>,
) -> Self {
assert!(
!(options.kamu_config.is_some() && generated_kamu_config.is_some()),
"There can be only one configuration file: either preset from the test options or \
generated based on the storage type"
);

if options.kamu_config.is_none() {
options.kamu_config = generated_kamu_config;
}

Self { options }
}

pub async fn run_api_server<Fixture, FixtureResult>(self, fixture: Fixture)
Expand Down Expand Up @@ -208,7 +224,8 @@ impl KamuCliApiServerHarness {
let KamuCliApiServerHarnessOptions {
potential_workspace,
env_vars,
frozen_system_time: freeze_system_time,
frozen_system_time,
kamu_config,
} = self.options;

let mut kamu = match potential_workspace {
Expand All @@ -218,14 +235,14 @@ impl KamuCliApiServerHarness {

KamuCliPuppet::new_workspace_tmp_with(NewWorkspaceOptions {
is_multi_tenant,
kamu_config: self.kamu_config,
kamu_config,
env_vars,
})
.await
}
};

kamu.set_system_time(freeze_system_time);
kamu.set_system_time(frozen_system_time);

kamu
}
Expand Down
Loading