Skip to content

Commit

Permalink
Fix review comments - Iter 1
Browse files Browse the repository at this point in the history
  • Loading branch information
rmn-boiko committed Feb 5, 2025
1 parent 4f52d8b commit 8dc0cba
Show file tree
Hide file tree
Showing 34 changed files with 74 additions and 471 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ jobs:
env:
SQLX_OFFLINE: false
DATABASE_URL: sqlite://kamu.sqlite.db
# platform(target) is a workaround for Windows only issue in cargo-nextest upon proc macro crates
run: cargo nextest run ${{ env.NEXTEST_FLAGS }} -E 'platform(target) & test(::sqlite::)'

- name: Postgres database tests
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ echo "SQLX_OFFLINE=false" >> $(2)/.env;
endef

.PHONY: sqlx-local-setup
sqlx-local-setup: sqlx-local-setup-postgres sqlx-local-setup-mariadb sqlx-local-setup-sqlite
sqlx-local-setup: sqlx-local-setup-postgres sqlx-local-setup-sqlite

.PHONY: sqlx-local-setup-postgres
sqlx-local-setup-postgres:
$(KAMU_CONTAINER_RUNTIME_TYPE) pull postgres:latest
$(KAMU_CONTAINER_RUNTIME_TYPE) stop kamu-postgres || true && $(KAMU_CONTAINER_RUNTIME_TYPE) rm kamu-postgres || true
$(KAMU_CONTAINER_RUNTIME_TYPE) run --name kamu-postgres -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -d postgres:latest
$(foreach crate,$(POSTGRES_CRATES),$(call Setup_EnvFile,postgres,5432,$(crate)))
$(KAMU_CONTAINER_RUNTIME_TYPE) stop kamu-node-postgres || true && $(KAMU_CONTAINER_RUNTIME_TYPE) rm kamu-node-postgres || true
$(KAMU_CONTAINER_RUNTIME_TYPE) run --name kamu-node-postgres -p 5433:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -d postgres:latest
$(foreach crate,$(POSTGRES_CRATES),$(call Setup_EnvFile,postgres,5433,$(crate)))
sleep 3 # Letting the container to start
until PGPASSWORD=root psql -h localhost -U root -p 5432 -d root -c '\q'; do sleep 3; done
sqlx database create --database-url postgres://root:root@localhost:5432/kamu
until PGPASSWORD=root psql -h localhost -U root -p 5433 -d root -c '\q'; do sleep 3; done
sqlx database create --database-url postgres://root:root@localhost:5433/kamu

.PHONY: sqlx-local-setup-sqlite
sqlx-local-setup-sqlite:
Expand All @@ -63,7 +63,7 @@ sqlx-local-setup-sqlite:

.PHONY: sqlx-local-clean-postgres
sqlx-local-clean-postgres:
$(KAMU_CONTAINER_RUNTIME_TYPE) stop kamu-postgres || true && $(KAMU_CONTAINER_RUNTIME_TYPE) rm kamu-postgres || true
$(KAMU_CONTAINER_RUNTIME_TYPE) stop kamu-node-postgres || true && $(KAMU_CONTAINER_RUNTIME_TYPE) rm kamu-node-postgres || true
$(foreach crate,$(POSTGRES_CRATES),rm $(crate)/.env -f ;)

.PHONY: sqlx-local-clean-sqlite
Expand Down
61 changes: 46 additions & 15 deletions resources/openapi-mt.json
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,20 @@
]
}
},
"/odata": {
"/odata/{account_name}": {
"get": {
"operationId": "odata_service_handler_st",
"operationId": "odata_service_handler_mt",
"parameters": [
{
"description": "Account name",
"in": "path",
"name": "account_name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
Expand All @@ -969,9 +980,20 @@
]
}
},
"/odata/$metadata": {
"/odata/{account_name}/$metadata": {
"get": {
"operationId": "odata_metadata_handler_st",
"operationId": "odata_metadata_handler_mt",
"parameters": [
{
"description": "Account name",
"in": "path",
"name": "account_name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
Expand All @@ -996,10 +1018,19 @@
]
}
},
"/odata/{dataset_name}": {
"/odata/{account_name}/{dataset_name}": {
"get": {
"operationId": "odata_collection_handler_st",
"operationId": "odata_collection_handler_mt",
"parameters": [
{
"description": "Account name",
"in": "path",
"name": "account_name",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "Dataset name",
"in": "path",
Expand Down Expand Up @@ -1473,7 +1504,7 @@
]
}
},
"/{dataset_name}/blocks/{block_hash}": {
"/{account_name}/{dataset_name}/blocks/{block_hash}": {
"get": {
"operationId": "dataset_blocks_handler",
"parameters": [
Expand Down Expand Up @@ -1529,7 +1560,7 @@
]
}
},
"/{dataset_name}/checkpoints/{physical_hash}": {
"/{account_name}/{dataset_name}/checkpoints/{physical_hash}": {
"get": {
"operationId": "dataset_checkpoints_get_handler",
"parameters": [
Expand Down Expand Up @@ -1654,7 +1685,7 @@
]
}
},
"/{dataset_name}/data/{physical_hash}": {
"/{account_name}/{dataset_name}/data/{physical_hash}": {
"get": {
"operationId": "dataset_data_get_handler",
"parameters": [
Expand Down Expand Up @@ -1779,7 +1810,7 @@
]
}
},
"/{dataset_name}/ingest": {
"/{account_name}/{dataset_name}/ingest": {
"post": {
"operationId": "dataset_ingest_handler",
"parameters": [
Expand Down Expand Up @@ -1856,7 +1887,7 @@
]
}
},
"/{dataset_name}/metadata": {
"/{account_name}/{dataset_name}/metadata": {
"get": {
"operationId": "dataset_metadata_handler",
"parameters": [
Expand Down Expand Up @@ -1921,7 +1952,7 @@
]
}
},
"/{dataset_name}/pull": {
"/{account_name}/{dataset_name}/pull": {
"get": {
"operationId": "dataset_pull_ws_upgrade_handler",
"parameters": [
Expand Down Expand Up @@ -1968,7 +1999,7 @@
]
}
},
"/{dataset_name}/push": {
"/{account_name}/{dataset_name}/push": {
"get": {
"operationId": "dataset_push_ws_upgrade_handler",
"parameters": [
Expand Down Expand Up @@ -2015,7 +2046,7 @@
]
}
},
"/{dataset_name}/refs/{reference}": {
"/{account_name}/{dataset_name}/refs/{reference}": {
"get": {
"operationId": "dataset_refs_handler",
"parameters": [
Expand Down Expand Up @@ -2071,7 +2102,7 @@
]
}
},
"/{dataset_name}/tail": {
"/{account_name}/{dataset_name}/tail": {
"get": {
"operationId": "dataset_tail_handler",
"parameters": [
Expand Down
35 changes: 2 additions & 33 deletions src/e2e/app/common/src/e2e_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::future::Future;
use kamu_node_puppet::extensions::KamuNodePuppetExt;
use kamu_node_puppet::{KamuNodePuppet, NewWorkspaceOptions};
use regex::Regex;
use sqlx::{MySqlPool, PgPool, SqlitePool};
use sqlx::{PgPool, SqlitePool};

use crate::{api_server_e2e_test, KamuApiServerClient};

Expand All @@ -22,7 +22,6 @@ use crate::{api_server_e2e_test, KamuApiServerClient};
pub struct KamuNodeApiServerHarnessOptions {
env_vars: Vec<(String, String)>,
kamu_config: Option<String>,
is_multi_tenant: bool,
}

impl KamuNodeApiServerHarnessOptions {
Expand All @@ -31,12 +30,6 @@ impl KamuNodeApiServerHarnessOptions {

self
}

pub fn with_multi_tenant(mut self) -> Self {
self.is_multi_tenant = true;

self
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -69,29 +62,6 @@ impl KamuNodeApiServerHarness {
Self::new(options, Some(kamu_config))
}

pub fn mysql(mysql_pool: &MySqlPool, options: KamuNodeApiServerHarnessOptions) -> Self {
let db = mysql_pool.connect_options();
let kamu_config = indoc::formatdoc!(
r#"
database:
provider: mySql
host: {host}
credentialsPolicy:
source:
kind: rawPassword
userName: {user}
rawPassword: {password}
databaseName: {database}
"#,
host = db.get_host(),
user = db.get_username(),
password = db.get_username(), // It's intended: password is same as user for tests
database = db.get_database().unwrap(),
);

Self::new(options, Some(kamu_config))
}

pub fn sqlite(sqlite_pool: &SqlitePool, options: KamuNodeApiServerHarnessOptions) -> Self {
// Ugly way to get the path as the settings have a not-so-good signature:
// SqliteConnectOptions::get_filename(self) -> Cow<'static, Path>
Expand Down Expand Up @@ -142,11 +112,10 @@ impl KamuNodeApiServerHarness {
Fixture: FnOnce(KamuApiServerClient) -> FixtureResult,
FixtureResult: Future<Output = ()> + Send + 'static,
{
let is_multi_tenant = self.options.is_multi_tenant;
let kamu = self.into_kamu();

let e2e_data_file_path = kamu.get_e2e_output_data_path();
let server_run_fut = kamu.start_api_server(e2e_data_file_path.clone(), is_multi_tenant);
let server_run_fut = kamu.start_api_server(e2e_data_file_path.clone());

api_server_e2e_test(e2e_data_file_path, server_run_fut, fixture).await;
}
Expand Down
2 changes: 0 additions & 2 deletions src/e2e/app/kamu-node-puppet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extensions = [
# External
"dep:async-trait",
"dep:indoc",
"dep:pretty_assertions",
"dep:serde",
]

Expand All @@ -39,7 +38,6 @@ tokio = { version = "1", default-features = false, features = ["rt"] }

async-trait = { optional = true, version = "0.1" }
indoc = { optional = true, version = "2" }
pretty_assertions = { optional = true, version = "1" }
serde = { optional = true, version = "1", default-features = false, features = [
"derive",
] }
Expand Down
6 changes: 6 additions & 0 deletions src/e2e/app/kamu-node-puppet/src/kamu_node_puppet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ impl KamuNodePuppet {
r#"
repo:
repoUrl: {path}
auth:
providers:
- kind: password
accounts:
- accountName: kamu
email: [email protected]
"#,
path = dataset_path.display()
));
Expand Down
Loading

0 comments on commit 8dc0cba

Please sign in to comment.