Skip to content

Commit

Permalink
E2E, test_ingest_command: stabilize order without the "match_time" ch…
Browse files Browse the repository at this point in the history
…anging
  • Loading branch information
s373r committed Oct 15, 2024
1 parent f43825a commit 051fc14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
12 changes: 3 additions & 9 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 @@ -104,33 +104,27 @@ lazy_static! {
};
}

/// NOTE: 1 millisecond for stable order within tests
///
/// <https://raw.githubusercontent.com/kamu-data/kamu-cli/refs/heads/master/examples/leaderboard/data/1.ndjson>
pub const DATASET_ROOT_PLAYER_SCORES_INGEST_DATA_NDJSON_CHUNK_1: &str = indoc::indoc!(
r#"
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Alice", "score": 100}
{"match_time": "2000-01-01 00:00:00.001", "match_id": 1, "player_id": "Bob", "score": 80}
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Bob", "score": 80}
"#
);

/// NOTE: 1 millisecond for stable order within tests
///
/// <https://raw.githubusercontent.com/kamu-data/kamu-cli/refs/heads/master/examples/leaderboard/data/2.ndjson>
pub const DATASET_ROOT_PLAYER_SCORES_INGEST_DATA_NDJSON_CHUNK_2: &str = indoc::indoc!(
r#"
{"match_time": "2000-01-02", "match_id": 2, "player_id": "Alice", "score": 70}
{"match_time": "2000-01-02 00:00:00.001", "match_id": 2, "player_id": "Charlie", "score": 90}
{"match_time": "2000-01-02", "match_id": 2, "player_id": "Charlie", "score": 90}
"#
);

/// NOTE: 1 millisecond for stable order within tests
///
/// <https://raw.githubusercontent.com/kamu-data/kamu-cli/refs/heads/master/examples/leaderboard/data/3.ndjson>
pub const DATASET_ROOT_PLAYER_SCORES_INGEST_DATA_NDJSON_CHUNK_3: &str = indoc::indoc!(
r#"
{"match_time": "2000-01-03", "match_id": 3, "player_id": "Bob", "score": 60}
{"match_time": "2000-01-03 00:00:00.001", "match_id": 3, "player_id": "Charlie", "score": 110}
{"match_time": "2000-01-03", "match_id": 3, "player_id": "Charlie", "score": 110}
"#
);

Expand Down
16 changes: 8 additions & 8 deletions src/e2e/app/cli/repo-tests/src/commands/test_ingest_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ pub async fn test_ingest_from_stdin(kamu: KamuCliPuppet) {
┌────┬──────────────────────┬──────────────────────┬──────────┬───────────┬───────┐
│ op │ system_time │ match_time │ match_id │ player_id │ score │
├────┼──────────────────────┼──────────────────────┼──────────┼───────────┼───────┤
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Bob │ 80 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
└────┴──────────────────────┴──────────────────────┴──────────┴───────────┴───────┘
"#
),
Expand All @@ -215,8 +215,8 @@ pub async fn test_ingest_from_stdin(kamu: KamuCliPuppet) {
┌────┬──────────────────────┬──────────────────────┬──────────┬───────────┬───────┐
│ op │ system_time │ match_time │ match_id │ player_id │ score │
├────┼──────────────────────┼──────────────────────┼──────────┼───────────┼───────┤
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Bob │ 80 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Alice │ 70 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Charlie │ 90 │
└────┴──────────────────────┴──────────────────────┴──────────┴───────────┴───────┘
Expand All @@ -234,8 +234,8 @@ pub async fn test_ingest_from_stdin(kamu: KamuCliPuppet) {
┌────┬──────────────────────┬──────────────────────┬──────────┬───────────┬───────┐
│ op │ system_time │ match_time │ match_id │ player_id │ score │
├────┼──────────────────────┼──────────────────────┼──────────┼───────────┼───────┤
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Bob │ 80 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Alice │ 70 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Charlie │ 90 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-03T00:00:00Z │ 3 │ Bob │ 60 │
Expand Down Expand Up @@ -326,8 +326,8 @@ pub async fn test_ingest_with_source_name(kamu: KamuCliPuppet) {
┌────┬──────────────────────┬──────────────────────┬──────────┬───────────┬───────┐
│ op │ system_time │ match_time │ match_id │ player_id │ score │
├────┼──────────────────────┼──────────────────────┼──────────┼───────────┼───────┤
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Bob │ 80 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
└────┴──────────────────────┴──────────────────────┴──────────┴───────────┴───────┘
"#
),
Expand All @@ -349,8 +349,8 @@ pub async fn test_ingest_with_source_name(kamu: KamuCliPuppet) {
┌────┬──────────────────────┬──────────────────────┬──────────┬───────────┬───────┐
│ op │ system_time │ match_time │ match_id │ player_id │ score │
├────┼──────────────────────┼──────────────────────┼──────────┼───────────┼───────┤
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Bob │ 80 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Alice │ 70 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Charlie │ 90 │
└────┴──────────────────────┴──────────────────────┴──────────┴───────────┴───────┘
Expand All @@ -374,8 +374,8 @@ pub async fn test_ingest_with_source_name(kamu: KamuCliPuppet) {
┌────┬──────────────────────┬──────────────────────┬──────────┬───────────┬───────┐
│ op │ system_time │ match_time │ match_id │ player_id │ score │
├────┼──────────────────────┼──────────────────────┼──────────┼───────────┼───────┤
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Bob │ 80 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-01T00:00:00Z │ 1 │ Alice │ 100 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Alice │ 70 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-02T00:00:00Z │ 2 │ Charlie │ 90 │
│ 0 │ 2050-01-02T03:04:05Z │ 2000-01-03T00:00:00Z │ 3 │ Bob │ 60 │
Expand Down Expand Up @@ -449,12 +449,12 @@ async fn assert_ingest_data_to_player_scores_from_stdio<I, S, T>(
r#"
SELECT op,
system_time,
DATE_TRUNC('second', match_time) as match_time,
match_time,
match_id,
player_id,
score
FROM "player-scores"
ORDER BY match_time;
ORDER BY match_id, score, player_id;
"#
),
"--output-format",
Expand Down

0 comments on commit 051fc14

Please sign in to comment.