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) ingest/inspect/log/new/reset/search/etc command tests #883

Merged
merged 41 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d490c1e
E2E, ingest_data_to_player_scores_from_stdio(): add
s373r Oct 8, 2024
d087c44
clippy fixes
s373r Oct 8, 2024
729312d
E2E, test_ingest_from_stdin(): also check data via the tail command
s373r Oct 8, 2024
570e97a
E2E, ingest_data_to_player_scores_from_stdio(): check data for all in…
s373r Oct 8, 2024
7b016ee
E2E, test_ingest_recursive(): add... a part of the test
s373r Oct 8, 2024
ef228c8
E2E, test_ingest_with_source_name(): add
s373r Oct 8, 2024
9609941
E2E, test_inspect_lineage(): add
s373r Oct 8, 2024
5db0a65
IngestCommand: add a todo
s373r Oct 9, 2024
02ec9b7
DATASET_ROOT_PLAYER_SCORES_INGEST_DATA_NDJSON_CHUNK_{1,2,3}: stabiliz…
s373r Oct 9, 2024
266d026
Rename: LineageCommand -> InspectLineageCommand
s373r Oct 9, 2024
51626c2
E2E: stabilize ingest command tests
s373r Oct 9, 2024
37a27ca
KamuCliPuppetExt::list_blocks(): add
s373r Oct 9, 2024
0c37099
E2E, test_inspect_query(): add
s373r Oct 9, 2024
e79fb7b
E2E, test_inspect_schema(): add
s373r Oct 9, 2024
7ae209b
kamu-cli, Login: fix a doc string typo
s373r Oct 9, 2024
c0d67f5
E2E, test_log(): add
s373r Oct 9, 2024
38f1486
E2E, test_new_{root,derivative}(): add
s373r Oct 9, 2024
ea12ca1
E2E, test_reset(): add
s373r Oct 9, 2024
31f5f6f
cli-reference.md: update
s373r Oct 9, 2024
df8b4db
test_repo_alias_command -> test_repo_command
s373r Oct 9, 2024
a9c04f5
E2E, KamuApiServerClientExt::ingest_data(): add
s373r Oct 10, 2024
0f680f4
E2E, test_search_multi_user(): add
s373r Oct 10, 2024
2654378
E2E, test_search_by_name(): add
s373r Oct 10, 2024
f8e0346
E2E, test_search_by_repo(): add
s373r Oct 10, 2024
9e82a79
E2E, test_sql_command(): add
s373r Oct 10, 2024
5120193
E2E, test_gc(): add
s373r Oct 10, 2024
4c48fb9
E2E, test_system_info(): add
s373r Oct 10, 2024
a086e62
E2E, test_system_diagnose(): add
s373r Oct 10, 2024
1a46de8
CI: test fixes
s373r Oct 10, 2024
2bddf18
assert_ingest_data_to_player_scores_from_stdio(): stabilize rows order
s373r Oct 10, 2024
9ca7ff6
assert_ingest_data_to_player_scores_from_stdio(): stabilize rows orde…
s373r Oct 10, 2024
48c61ae
test_sql_command(): use the default name
s373r Oct 10, 2024
44b9484
assert_ingest_data_to_player_scores_from_stdio(): stabilize rows orde…
s373r Oct 10, 2024
6d0d750
CHANGELOG.md: update
s373r Oct 10, 2024
702467f
CI: windows build fixes
s373r Oct 10, 2024
a5494b8
E2E, test_tail(): add
s373r Oct 10, 2024
c4d349b
assert_ingest_data_to_player_scores_from_stdio(): stabilize rows orde…
s373r Oct 10, 2024
d83c4b1
assert_ingest_data_to_player_scores_from_stdio(): stabilize rows orde…
s373r Oct 11, 2024
96d6a34
pretty_assertions::assert_eq!(): expected first, actual after
s373r Oct 11, 2024
2ecc8cb
Remove extra files
s373r Oct 11, 2024
67718ff
E2E: cover "kamu login" / "kamu logout" commands
s373r Oct 11, 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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ Recommendation: for ease of reading, use the following order:
- `kamu init` command
- `kamu add` command
- `kamu rename` command
- `kamu ingest` command
- `kamu inspect` command
- `kamu log` command
- `kamu new` command
- `kamu reset` command
- `kamu search` command
- `kamu sql` command
- `kamu system gc` command
- `kamu system info` command
- `kamu system diagnose` command
- `kamu tail` command
- `kamu login` command
- `kamu logout` 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
4 changes: 2 additions & 2 deletions resources/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To regenerate this schema from existing code, use the following command:
* `inspect` — Group of commands for exploring dataset metadata
* `list [ls]` — List all datasets in the workspace
* `log` — Shows dataset metadata history
* `login`Authentiates with a remote ODF server interactively
* `login`Authenticates with a remote ODF server interactively
* `logout` — Logs out from a remote Kamu server
* `new` — Creates a new dataset manifest from a template
* `notebook` — Starts the notebook server for exploring the data in the workspace
Expand Down Expand Up @@ -508,7 +508,7 @@ Using a filter to inspect blocks containing query changes of a derivative datase

## `kamu login`

Authentiates with a remote ODF server interactively
Authenticates with a remote ODF server interactively

**Usage:** `kamu login [OPTIONS] [SERVER] [COMMAND]`

Expand Down
2 changes: 2 additions & 0 deletions src/adapter/graphql/src/mutations/datasets_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ impl DatasetsMut {
}

// TODO: Multi-tenancy
// https://github.com/kamu-data/kamu-cli/issues/891

// TODO: Multi-tenant resolution for derivative dataset inputs (should it only
// work by ID?)
#[allow(unused_variables)]
Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ pub struct Log {

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

/// Authentiates with a remote ODF server interactively
/// Authenticates with a remote ODF server interactively
#[derive(Debug, clap::Args)]
pub struct Login {
#[command(subcommand)]
Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/src/cli_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub fn get_command(
}
}
cli::Command::Inspect(c) => match c.subcommand {
cli::InspectSubCommand::Lineage(sc) => Box::new(LineageCommand::new(
cli::InspectSubCommand::Lineage(sc) => Box::new(InspectLineageCommand::new(
cli_catalog.get_one()?,
cli_catalog.get_one()?,
cli_catalog.get_one()?,
Expand Down
2 changes: 2 additions & 0 deletions src/app/cli/src/commands/ingest_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ impl Command for IngestCommand {
_ => Ok(()),
}?;

// TODO: `kamu ingest`: implement `--recursive` mode
// https://github.com/kamu-data/kamu-cli/issues/886
if self.recursive {
unimplemented!("Sorry, recursive ingest is not yet implemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum LineageOutputFormat {

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

pub struct LineageCommand {
pub struct InspectLineageCommand {
dataset_repo: Arc<dyn DatasetRepository>,
provenance_svc: Arc<dyn ProvenanceService>,
workspace_layout: Arc<WorkspaceLayout>,
Expand All @@ -41,7 +41,7 @@ pub struct LineageCommand {
output_config: Arc<OutputConfig>,
}

impl LineageCommand {
impl InspectLineageCommand {
pub fn new<I>(
dataset_repo: Arc<dyn DatasetRepository>,
provenance_svc: Arc<dyn ProvenanceService>,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl LineageCommand {

// TODO: Support temporality and evolution
#[async_trait::async_trait(?Send)]
impl Command for LineageCommand {
impl Command for InspectLineageCommand {
async fn run(&mut self) -> Result<(), CLIError> {
use futures::{StreamExt, TryStreamExt};
let mut dataset_handles: Vec<_> = if self.dataset_refs.is_empty() {
Expand Down
2 changes: 2 additions & 0 deletions src/app/cli/src/commands/log_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use crate::output::OutputConfig;
pub enum MetadataLogOutputFormat {
Shell,
Yaml,
// TODO: `kamu log`: support `--output-format json`
// https://github.com/kamu-data/kamu-cli/issues/887
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions src/app/cli/src/commands/login_silent_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ use crate::{odf_server, CLIError, Command};

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

#[derive(Debug)]
pub enum LoginSilentMode {
OAuth(LoginSilentModeOAuth),
Password(LoginSilentModePassword),
}

#[derive(Debug)]
pub struct LoginSilentModeOAuth {
pub provider: String,
pub access_token: String,
}

#[derive(Debug)]
pub struct LoginSilentModePassword {
pub login: String,
pub password: String,
Expand Down
4 changes: 2 additions & 2 deletions src/app/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ mod delete_command;
mod gc_command;
mod ingest_command;
mod init_command;
mod inspect_lineage_command;
mod inspect_query_command;
mod inspect_schema_command;
mod lineage_command;
mod list_command;
mod log_command;
mod login_command;
Expand Down Expand Up @@ -71,9 +71,9 @@ pub use delete_command::*;
pub use gc_command::*;
pub use ingest_command::*;
pub use init_command::*;
pub use inspect_lineage_command::*;
pub use inspect_query_command::*;
pub use inspect_schema_command::*;
pub use lineage_command::*;
pub use list_command::*;
pub use log_command::*;
pub use login_command::*;
Expand Down
4 changes: 4 additions & 0 deletions src/app/cli/src/commands/reset_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use opendatafabric::*;
use super::{CLIError, Command};
use crate::Interact;

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

pub struct ResetCommand {
interact: Arc<Interact>,
dataset_repo: Arc<dyn DatasetRepository>,
Expand Down Expand Up @@ -66,3 +68,5 @@ impl Command for ResetCommand {
Ok(())
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4 changes: 4 additions & 0 deletions src/app/cli/src/commands/tail_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use opendatafabric::*;
use super::{CLIError, Command};
use crate::output::*;

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

pub struct TailCommand {
query_svc: Arc<dyn QueryService>,
dataset_ref: DatasetRef,
Expand Down Expand Up @@ -93,3 +95,5 @@ impl Command for TailCommand {
Ok(())
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17 changes: 12 additions & 5 deletions src/app/cli/src/services/gc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@

use std::sync::Arc;

use chrono::{DateTime, Duration, Utc};
use chrono::{DateTime, Duration, TimeDelta, Utc};
use internal_error::{InternalError, ResultIntoInternal};

use crate::WorkspaceLayout;

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

const EVICTION_THRESHOLD: TimeDelta = Duration::hours(24);

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

pub struct GcService {
workspace_layout: Arc<WorkspaceLayout>,
}
Expand Down Expand Up @@ -56,9 +62,6 @@ impl GcService {
/// Evict stale entries to manage cache size
#[tracing::instrument(level = "debug", skip_all)]
pub fn evict_cache(&self) -> Result<GcResult, InternalError> {
// TODO: Make const after https://github.com/chronotope/chrono/issues/309
// Or make into a config option
let eviction_threshold: Duration = Duration::hours(24);
let now = Utc::now();
let mut entries_freed = 0;
let mut bytes_freed = 0;
Expand All @@ -69,7 +72,7 @@ impl GcService {
let mtime: DateTime<Utc> =
chrono::DateTime::from(entry.metadata().int_err()?.modified().int_err()?);

if (now - mtime) > eviction_threshold {
if (now - mtime) > EVICTION_THRESHOLD {
if entry.path().is_dir() {
bytes_freed += fs_extra::dir::get_size(entry.path()).int_err()?;
std::fs::remove_dir_all(entry.path()).int_err()?;
Expand All @@ -93,7 +96,11 @@ impl GcService {
}
}

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

pub struct GcResult {
pub entries_freed: usize,
pub bytes_freed: u64,
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4 changes: 4 additions & 0 deletions src/domain/core/src/services/reset_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use thiserror::Error;
use crate::entities::SetRefError;
use crate::*;

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

#[async_trait::async_trait]
pub trait ResetService: Send + Sync {
async fn reset_dataset(
Expand Down Expand Up @@ -103,3 +105,5 @@ pub struct OldHeadMismatchError {
pub current_head: Multihash,
pub old_head: Multihash,
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12 changes: 9 additions & 3 deletions src/e2e/app/cli/common/src/e2e_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use std::future::Future;

use chrono::{DateTime, NaiveTime, Utc};
use chrono::{DateTime, NaiveTime, TimeZone, Utc};
use kamu_cli_puppet::extensions::KamuCliPuppetExt;
use kamu_cli_puppet::{KamuCliPuppet, NewWorkspaceOptions};
use regex::Regex;
Expand Down Expand Up @@ -55,12 +55,18 @@ impl KamuCliApiServerHarnessOptions {
self
}

pub fn with_frozen_system_time(mut self, value: DateTime<Utc>) -> Self {
pub fn with_custom_frozen_system_time(mut self, value: DateTime<Utc>) -> Self {
self.frozen_system_time = Some(value);

self
}

pub fn with_frozen_system_time(self) -> Self {
let t = Utc.with_ymd_and_hms(2050, 1, 2, 3, 4, 5).unwrap();

self.with_custom_frozen_system_time(t)
}

pub fn with_today_as_frozen_system_time(self) -> Self {
let today = {
let now = Utc::now();
Expand All @@ -69,7 +75,7 @@ impl KamuCliApiServerHarnessOptions {
.unwrap()
};

self.with_frozen_system_time(today)
self.with_custom_frozen_system_time(today)
}

pub fn with_kamu_config(mut self, content: &str) -> Self {
Expand Down
Loading
Loading