Skip to content

Commit

Permalink
Merge pull request #47 from axiomhq/arne/axm-12-test-axiom-rust-again…
Browse files Browse the repository at this point in the history
…st-staging

Run unit tests against staging as well
  • Loading branch information
bahlo authored May 11, 2023
2 parents b82db9b + ee0ba41 commit 745914c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 10 additions & 7 deletions tests/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
},
Expand All @@ -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,
Expand All @@ -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());
}

0 comments on commit 745914c

Please # to comment.