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

Prefix dataset alias with account name #1008

Merged
merged 5 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Recommendation: for ease of reading, use the following order:
- Fixed
-->

## [Unreleased]
### Fixed
- GraphQL: in a multi-tenant workspace, `datasets.createEmpty` and `datasets.createFromSnapshot` mutations now return dataset aliases prefixed with account name.

## [0.215.0] - 2024-12-27
### Added
- New entity `FlowTrigger` which is now responsible for flow activation and schedules
Expand Down
15 changes: 14 additions & 1 deletion src/adapter/graphql/tests/tests/test_gql_datasets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,20 @@ async fn dataset_create_empty() {

#[test_log::test(tokio::test)]
async fn dataset_create_from_snapshot() {
let harness = GraphQLDatasetsHarness::new(TenancyConfig::MultiTenant).await;
let mut mock_authentication_service = MockAuthenticationService::built_in();
mock_authentication_service
.expect_account_by_name()
.returning(|_| {
Ok(Some(Account::test(
AccountID::new(DidOdf::new_seeded_ed25519(&[1, 2, 3])),
"kamu",
)))
});
let harness = GraphQLDatasetsHarness::new_custom_authentication(
mock_authentication_service,
TenancyConfig::MultiTenant,
)
.await;

let snapshot = MetadataFactory::dataset_snapshot()
.name("foo")
Expand Down
22 changes: 11 additions & 11 deletions src/e2e/app/cli/common/src/kamu_api_server_client_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use kamu_adapter_http::{LoginRequestBody, PlatformFileUploadQuery, UploadContext
use kamu_core::BlockRef;
use kamu_flow_system::{DatasetFlowType, FlowID};
use lazy_static::lazy_static;
use opendatafabric as odf;
use opendatafabric::{self as odf, DatasetAlias};
use reqwest::{Method, StatusCode, Url};
use thiserror::Error;
use tokio_retry::strategy::FixedInterval;
Expand Down Expand Up @@ -155,6 +155,7 @@ pub const E2E_USER_ACCOUNT_NAME_STR: &str = "e2e-user";

pub struct CreateDatasetResponse {
pub dataset_id: odf::DatasetID,
pub dataset_alias: DatasetAlias,
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -439,9 +440,12 @@ impl DatasetApi<'_> {
pretty_assertions::assert_eq!(Some("Success"), create_response_node["message"].as_str());

let dataset_id_as_str = create_response_node["dataset"]["id"].as_str().unwrap();
let alias_str = create_response_node["dataset"]["alias"].as_str().unwrap();
let dataset_alias = alias_str.parse().unwrap();

CreateDatasetResponse {
dataset_id: odf::DatasetID::from_did_str(dataset_id_as_str).unwrap(),
dataset_alias,
}
}

Expand All @@ -458,6 +462,7 @@ impl DatasetApi<'_> {
... on CreateDatasetResultSuccess {
dataset {
id
alias
}
}
}
Expand All @@ -475,9 +480,12 @@ impl DatasetApi<'_> {
pretty_assertions::assert_eq!(Some("Success"), create_response_node["message"].as_str());

let dataset_id_as_str = create_response_node["dataset"]["id"].as_str().unwrap();
let alias_str = create_response_node["dataset"]["alias"].as_str().unwrap();
let dataset_alias = alias_str.parse().unwrap();

CreateDatasetResponse {
dataset_id: odf::DatasetID::from_did_str(dataset_id_as_str).unwrap(),
dataset_alias,
}
}

Expand All @@ -486,19 +494,11 @@ impl DatasetApi<'_> {
.await
}

pub async fn create_player_scores_dataset_with_data(
&self,
account_name_maybe: Option<odf::AccountName>,
) -> CreateDatasetResponse {
pub async fn create_player_scores_dataset_with_data(&self) -> CreateDatasetResponse {
let create_response = self.create_player_scores_dataset().await;

// TODO: Use the alias from the reply, after fixing the bug:
// https://github.com/kamu-data/kamu-cli/issues/891
let dataset_alias =
odf::DatasetAlias::new(account_name_maybe, DATASET_ROOT_PLAYER_NAME.clone());

self.ingest_data(
&dataset_alias,
&create_response.dataset_alias,
RequestBody::NdJson(DATASET_ROOT_PLAYER_SCORES_INGEST_DATA_NDJSON_CHUNK_1.into()),
)
.await;
Expand Down
1 change: 1 addition & 0 deletions src/e2e/app/cli/inmem/tests/tests/rest_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
mod test_accounts;
mod test_auth;
mod test_dataset;
mod test_gql_query;
mod test_odf_core;
mod test_odf_query;
mod test_openapi;
Expand Down
46 changes: 46 additions & 0 deletions src/e2e/app/cli/inmem/tests/tests/rest_api/test_gql_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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_run_api_server_e2e_test!(
storage = inmem,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_empty_returns_correct_alias_mt,
options = Options::default().with_multi_tenant()
);

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

kamu_cli_run_api_server_e2e_test!(
storage = inmem,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_empty_returns_correct_alias_st
);

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

kamu_cli_run_api_server_e2e_test!(
storage = inmem,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_from_snapshot_returns_correct_alias_mt,
options = Options::default().with_multi_tenant()
);

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

kamu_cli_run_api_server_e2e_test!(
storage = inmem,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_from_snapshot_returns_correct_alias_st
);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 change: 1 addition & 0 deletions src/e2e/app/cli/postgres/tests/tests/rest_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
mod test_accounts;
mod test_auth;
mod test_dataset;
mod test_gql_query;
mod test_odf_core;
mod test_odf_query;
mod test_upload;
46 changes: 46 additions & 0 deletions src/e2e/app/cli/postgres/tests/tests/rest_api/test_gql_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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_run_api_server_e2e_test!(
storage = postgres,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_empty_returns_correct_alias_mt,
options = Options::default().with_multi_tenant()
);

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

kamu_cli_run_api_server_e2e_test!(
storage = postgres,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_empty_returns_correct_alias_st
);

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

kamu_cli_run_api_server_e2e_test!(
storage = postgres,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_from_snapshot_returns_correct_alias_mt,
options = Options::default().with_multi_tenant()
);

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

kamu_cli_run_api_server_e2e_test!(
storage = postgres,
fixture =
kamu_cli_e2e_repo_tests::rest_api::test_gql_query_mut_create_from_snapshot_returns_correct_alias_st
);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 changes: 2 additions & 0 deletions src/e2e/app/cli/repo-tests/src/rest_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
mod test_accounts;
mod test_auth;
mod test_dataset;
mod test_gql_query;
mod test_odf_core;
mod test_odf_query;
mod test_openapi;
Expand All @@ -19,6 +20,7 @@ mod test_upload;
pub use test_accounts::*;
pub use test_auth::*;
pub use test_dataset::*;
pub use test_gql_query::*;
pub use test_odf_core::*;
pub use test_odf_query::*;
pub use test_openapi::*;
Expand Down
2 changes: 1 addition & 1 deletion src/e2e/app/cli/repo-tests/src/rest_api/test_dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn test_datasets_by_id(mut kamu_api_server_client: KamuApiServerClient
);
// <--

let CreateDatasetResponse { dataset_id } = kamu_api_server_client
let CreateDatasetResponse { dataset_id, .. } = kamu_api_server_client
.dataset()
.create_player_scores_dataset()
.await;
Expand Down
Loading
Loading