Skip to content

Commit

Permalink
Revert to tracing_integration_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VianneyRuhlmann committed Sep 25, 2024
1 parent 9756cd4 commit d89b6e4
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 116 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ jobs:
- name: "[${{ steps.rust-version.outputs.version}}] cargo build --workspace --exclude builder --verbose"
shell: bash
run: cargo build --workspace --exclude builder --verbose
- name: "[${{ steps.rust-version.outputs.version}}] cargo nextest run --workspace --exclude builder --profile ci --verbose -E '!test(require_test_agent::)'"
- name: "[${{ steps.rust-version.outputs.version}}] cargo nextest run --workspace --exclude builder --profile ci --verbose -E '!test(tracing_integration_tests::)'"
shell: bash
# Run doc tests with cargo test and run tests with nextest and generate junit.xml
run: cargo test --workspace --exclude builder --doc --verbose && cargo nextest run --workspace --exclude builder --profile ci --verbose -E '!test(require_test_agent::)'
run: cargo test --workspace --exclude builder --doc --verbose && cargo nextest run --workspace --exclude builder --profile ci --verbose -E '!test(tracing_integration_tests::)'
env:
RUST_BACKTRACE: 1
- name: "[${{ steps.rust-version.outputs.version}}] Test agent tests: cargo nextest run --workspace --exclude builder --profile ci --verbose -E 'test(require_test_agent::)'"
- name: "[${{ steps.rust-version.outputs.version}}] Tracing integration tests: cargo nextest run --workspace --exclude builder --profile ci --verbose -E 'test(tracing_integration_tests::)'"
if: runner.os == 'Linux'
shell: bash
run: cargo nextest run --workspace --exclude builder --profile ci --verbose -E 'test(require_test_agent::)'
run: cargo nextest run --workspace --exclude builder --profile ci --verbose -E 'test(tracing_integration_tests::)'
env:
RUST_BACKTRACE: 1
- name: "[${{ steps.rust-version.outputs.version}}] RUSTFLAGS=\"-C prefer-dynamic\" cargo nextest run --package test_spawn_from_lib --features prefer-dynamic -E '!test(require_test_agent::)'"
- name: "[${{ steps.rust-version.outputs.version}}] RUSTFLAGS=\"-C prefer-dynamic\" cargo nextest run --package test_spawn_from_lib --features prefer-dynamic -E '!test(tracing_integration_tests::)'"
shell: bash
run: cargo nextest run --package test_spawn_from_lib --features prefer-dynamic -E '!test(require_test_agent::)'
run: cargo nextest run --package test_spawn_from_lib --features prefer-dynamic -E '!test(tracing_integration_tests::)'
env:
RUSTFLAGS: "-C prefer-dynamic"
RUST_BACKTRACE: 1
Expand Down Expand Up @@ -220,8 +220,8 @@ jobs:
rust_version: cross-centos7
- run: cargo install cross || true
- run: cross build --workspace --target x86_64-unknown-linux-gnu --exclude builder
- run: cross test --workspace --target x86_64-unknown-linux-gnu --exclude builder -- --skip "::single_threaded_tests::" --skip "require_test_agent::"
- run: cross test --workspace --target x86_64-unknown-linux-gnu --exclude builder --exclude bin_tests -- --skip "::tests::" --skip "::api_tests::" --test-threads 1 --skip "require_test_agent::"
- run: cross test --workspace --target x86_64-unknown-linux-gnu --exclude builder -- --skip "::single_threaded_tests::" --skip "tracing_integration_tests::"
- run: cross test --workspace --target x86_64-unknown-linux-gnu --exclude builder --exclude bin_tests -- --skip "::tests::" --skip "::api_tests::" --test-threads 1 --skip "tracing_integration_tests::"

ffi_bake:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ cargo install --locked 'cargo-nextest@0.9.67'
Tracing integration tests require docker to be installed and running. If you don't have docker installed or you want to skip these tests, you can run:

```bash
cargo nextest run -E '!test(::require_test_agent::)'
cargo nextest run -E '!test(tracing_integration_tests::)'
```

Please note that the locked version is to make sure that it can be built using rust `1.76.0`, and if you are using a newer rust version, then it's enough to limit the version to `0.9.*`.
Expand Down
100 changes: 46 additions & 54 deletions data-pipeline/tests/test_fetch_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,56 @@
// SPDX-License-Identifier: Apache-2.0

#[cfg(test)]
mod require_test_agent {
mod fetch_info_test {
use data_pipeline::agent_info::fetch_info;
use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent;
use ddcommon::Endpoint;
mod tracing_integration_tests {
use arc_swap::access::Access;
use data_pipeline::agent_info::{fetch_info, AgentInfoFetcher};
use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent;
use ddcommon::Endpoint;
use std::time::Duration;

#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn test_fetch_info_from_test_agent() {
let test_agent = DatadogTestAgent::new(None).await;
let endpoint = Endpoint::from_url(test_agent.get_uri_for_endpoint("info", None).await);
let info = fetch_info(&endpoint)
.await
.expect("Failed to fetch agent info");
assert!(
info.info
.version
.expect("Missing version field in agent response")
== "test"
);
}
#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn test_fetch_info_from_test_agent() {
let test_agent = DatadogTestAgent::new(None).await;
let endpoint = Endpoint::from_url(test_agent.get_uri_for_endpoint("info", None).await);
let info = fetch_info(&endpoint)
.await
.expect("Failed to fetch agent info");
assert!(
info.info
.version
.expect("Missing version field in agent response")
== "test"
);
}

mod agent_info_fetcher_test {
use arc_swap::access::Access;
use data_pipeline::agent_info::AgentInfoFetcher;
use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent;
use ddcommon::Endpoint;
use std::time::Duration;
#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn test_agent_info_fetcher_with_test_agent() {
let test_agent = DatadogTestAgent::new(None).await;
let endpoint = Endpoint::from_url(test_agent.get_uri_for_endpoint("info", None).await);
let fetcher = AgentInfoFetcher::new(endpoint, Duration::from_secs(1));
let info_arc = fetcher.get_info();
tokio::spawn(async move { fetcher.run().await });
let info_received = async {
while info_arc.load().is_none() {
tokio::time::sleep(Duration::from_millis(500)).await;
}
info_arc.load()
};

#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn test_agent_info_fetcher_with_test_agent() {
let test_agent = DatadogTestAgent::new(None).await;
let endpoint = Endpoint::from_url(test_agent.get_uri_for_endpoint("info", None).await);
let fetcher = AgentInfoFetcher::new(endpoint, Duration::from_secs(1));
let info_arc = fetcher.get_info();
tokio::spawn(async move { fetcher.run().await });
let info_received = async {
while info_arc.load().is_none() {
tokio::time::sleep(Duration::from_millis(500)).await;
}
info_arc.load()
};
let info = tokio::time::timeout(Duration::from_secs(10), info_received)
.await
.expect("Agent request timed out");

let info = tokio::time::timeout(Duration::from_secs(10), info_received)
.await
.expect("Agent request timed out");

assert!(
info.as_ref()
.unwrap()
.info
.version
.clone()
.expect("Missing version field in agent response")
== "test"
);
}
assert!(
info.as_ref()
.unwrap()
.info
.version
.clone()
.expect("Missing version field in agent response")
== "test"
);
}
}
104 changes: 51 additions & 53 deletions trace-utils/tests/test_send_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,66 @@
// SPDX-License-Identifier: Apache-2.0

#[cfg(test)]
mod require_test_agent {
mod tracing_integration_tests {
use datadog_trace_utils::send_data::SendData;
use datadog_trace_utils::test_utils::create_test_no_alloc_span;
use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent;
use datadog_trace_utils::trace_utils::TracerHeaderTags;
use datadog_trace_utils::tracer_payload::TracerPayloadCollection;
use ddcommon::Endpoint;
use tinybytes::BytesString;
mod tracing_integration_tests {
use datadog_trace_utils::send_data::SendData;
use datadog_trace_utils::test_utils::create_test_no_alloc_span;
use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent;
use datadog_trace_utils::trace_utils::TracerHeaderTags;
use datadog_trace_utils::tracer_payload::TracerPayloadCollection;
use ddcommon::Endpoint;
use tinybytes::BytesString;

#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn compare_v04_trace_snapshot_test() {
let relative_snapshot_path = "trace-utils/tests/snapshots/";
let test_agent = DatadogTestAgent::new(Some(relative_snapshot_path)).await;
#[cfg_attr(miri, ignore)]
#[tokio::test]
async fn compare_v04_trace_snapshot_test() {
let relative_snapshot_path = "trace-utils/tests/snapshots/";
let test_agent = DatadogTestAgent::new(Some(relative_snapshot_path)).await;

let header_tags = TracerHeaderTags {
lang: "test-lang",
lang_version: "2.0",
lang_interpreter: "interpreter",
lang_vendor: "vendor",
tracer_version: "1.0",
container_id: "id",
client_computed_top_level: false,
client_computed_stats: false,
};
let header_tags = TracerHeaderTags {
lang: "test-lang",
lang_version: "2.0",
lang_interpreter: "interpreter",
lang_vendor: "vendor",
tracer_version: "1.0",
container_id: "id",
client_computed_top_level: false,
client_computed_stats: false,
};

let endpoint = Endpoint::from_url(
test_agent
.get_uri_for_endpoint("v0.4/traces", Some("compare_v04_trace_snapshot_test"))
.await,
);
let endpoint = Endpoint::from_url(
test_agent
.get_uri_for_endpoint("v0.4/traces", Some("compare_v04_trace_snapshot_test"))
.await,
);

let mut span_1 = create_test_no_alloc_span(1234, 12342, 12341, 1, false);
span_1.metrics.insert(
BytesString::from_slice("_dd_metric1".as_ref()).unwrap(),
1.0,
);
span_1.metrics.insert(
BytesString::from_slice("_dd_metric2".as_ref()).unwrap(),
2.0,
);
let mut span_1 = create_test_no_alloc_span(1234, 12342, 12341, 1, false);
span_1.metrics.insert(
BytesString::from_slice("_dd_metric1".as_ref()).unwrap(),
1.0,
);
span_1.metrics.insert(
BytesString::from_slice("_dd_metric2".as_ref()).unwrap(),
2.0,
);

let span_2 = create_test_no_alloc_span(1234, 12343, 12341, 1, false);
let span_2 = create_test_no_alloc_span(1234, 12343, 12341, 1, false);

let mut root_span = create_test_no_alloc_span(1234, 12341, 0, 0, true);
root_span.r#type = BytesString::from_slice("web".as_ref()).unwrap();
let mut root_span = create_test_no_alloc_span(1234, 12341, 0, 0, true);
root_span.r#type = BytesString::from_slice("web".as_ref()).unwrap();

let trace = vec![span_1, span_2, root_span];
let trace = vec![span_1, span_2, root_span];

let data = SendData::new(
300,
TracerPayloadCollection::V04(vec![trace.clone()]),
header_tags,
&endpoint,
);
let data = SendData::new(
300,
TracerPayloadCollection::V04(vec![trace.clone()]),
header_tags,
&endpoint,
);

let _result = data.send().await;
let _result = data.send().await;

test_agent
.assert_snapshot("compare_v04_trace_snapshot_test")
.await;
}
test_agent
.assert_snapshot("compare_v04_trace_snapshot_test")
.await;
}
}

0 comments on commit d89b6e4

Please sign in to comment.