diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 875c433..7a7f4e4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,6 +10,11 @@ on: tags: - "v*" +# Make sure the workflow is only ever run for the latest changes in the PR. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: rust_fmt_check: name: Rustfmt check @@ -51,15 +56,24 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} test: - name: Run tests on ${{ matrix.runtime }} + name: Run tests with ${{ matrix.runtime }} on ${{ matrix.environment }} runs-on: ubuntu-latest strategy: max-parallel: 1 matrix: + runtime: [Tokio, async-std] + environment: [development, staging] include: - - runtime: Tokio - runtime: async-std flags: --no-default-features --features async-std,default-tls + - environment: development + url: TESTING_DEV_API_URL + token: TESTING_DEV_TOKEN + org_id: TESTING_DEV_ORG_ID + - environment: staging + url: TESTING_STAGING_API_URL + token: TESTING_STAGING_TOKEN + org_id: TESTING_STAGING_ORG_ID steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -74,9 +88,9 @@ jobs: - name: Run cargo test uses: actions-rs/cargo@v1 env: - AXIOM_URL: ${{ secrets.TESTING_DEV_API_URL }} - AXIOM_TOKEN: ${{ secrets.TESTING_DEV_TOKEN }} - AXIOM_ORG_ID: ${{ secrets.TESTING_DEV_ORG_ID }} + AXIOM_URL: ${{ secrets[matrix.url] }} + AXIOM_TOKEN: ${{ secrets[matrix.token] }} + AXIOM_ORG_ID: ${{ secrets[matrix.org_id] }} AXIOM_DATASET_SUFFIX: ${{ github.run_id }} with: command: test diff --git a/tests/cursor.rs b/tests/cursor.rs index 7aedde3..381a8ef 100644 --- a/tests/cursor.rs +++ b/tests/cursor.rs @@ -81,9 +81,10 @@ async fn test_cursor_impl(ctx: &mut Context) { let mut events = Vec::new(); // iterate 1000 times - for i in 0..1000 { + let event_time = Utc::now(); + for _ in 0..1000 { events.push(json!({ - "_time": (Utc::now() + Duration::seconds(i)), + "_time": event_time, "remote_ip": "93.180.71.2", "remote_user": "-", "request": "GET /downloads/product_1 HTTP/1.1", @@ -99,13 +100,16 @@ async fn test_cursor_impl(ctx: &mut Context) { assert_eq!(ingest_status.failed, 0); assert_eq!(ingest_status.failures.len(), 0); + let start_time = Utc::now() - Duration::minutes(1); + let end_time = Utc::now() + Duration::minutes(1); + let apl_query_result = ctx .client .query( format!("['{}'] | sort by _time desc", ctx.dataset.name), QueryOptions { - start_time: Some(Utc::now() - Duration::minutes(1)), - end_time: Some(Utc::now() + Duration::minutes(20)), + start_time: Some(start_time), + end_time: Some(end_time), save: true, ..Default::default() }, @@ -122,8 +126,8 @@ async fn test_cursor_impl(ctx: &mut Context) { .query( format!("['{}'] | sort by _time desc", ctx.dataset.name), QueryOptions { - start_time: Some(apl_query_result.matches[500].time), - end_time: Some(Utc::now() + Duration::minutes(20)), + start_time: Some(start_time), + end_time: Some(end_time), include_cursor: true, cursor: Some(mid_row_id.to_string()), save: true, @@ -132,7 +136,6 @@ async fn test_cursor_impl(ctx: &mut Context) { ) .await .unwrap(); - assert!(apl_query_result.saved_query_id.is_some()); assert_eq!(500, apl_query_result.matches.len()); }