Skip to content

Commit 70d6cea

Browse files
committed
fix(dev): use release build of ADP for local correctness test runs
1 parent eb64b2e commit 70d6cea

File tree

8 files changed

+61
-17
lines changed

8 files changed

+61
-17
lines changed

.gitlab/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ test-integration:
124124
# Copy the bundled Agent/ADP image we built to the local Docker instance so we can share the integration
125125
# test configurations between CI and local test runs.
126126
- docker pull ${SALUKI_IMAGE_REPO_BASE}/bundled-agent-adp:${CI_COMMIT_SHA}
127-
- docker tag ${SALUKI_IMAGE_REPO_BASE}/bundled-agent-adp:${CI_COMMIT_SHA} saluki-images/datadog-agent:testing-devel
127+
- docker tag ${SALUKI_IMAGE_REPO_BASE}/bundled-agent-adp:${CI_COMMIT_SHA} saluki-images/datadog-agent:testing-release
128128
- make test-integration-quick

bin/correctness/millstone/src/driver.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::time::{Duration, Instant, SystemTime};
1+
use std::{
2+
path::PathBuf,
3+
time::{Duration, Instant, SystemTime},
4+
};
25

36
use bytesize::ByteSize;
47
use saluki_error::{ErrorContext as _, GenericError};
@@ -19,12 +22,19 @@ pub struct Driver {
1922
impl Driver {
2023
/// Creates a new `Driver` based on the given configuration.
2124
///
25+
/// If `output_file` is provided, the driver will write all payloads to the given file path instead of the
26+
/// configured target. The configured target is still used to determine corpus generation parameters (e.g.
27+
/// framing), so the bytes written to the file are identical to what would be sent over the wire.
28+
///
2229
/// # Errors
2330
///
2431
/// If an error occurs while creating the corpus, it will be returned.
25-
pub fn new(config: Config) -> Result<Self, GenericError> {
32+
pub fn new(config: Config, output_file: Option<PathBuf>) -> Result<Self, GenericError> {
2633
let corpus = Corpus::from_config(&config).error_context("Failed to generate test corpus.")?;
27-
let sender = TargetSender::from_config(&config).error_context("Failed to create target sender.")?;
34+
let sender = match output_file {
35+
Some(path) => TargetSender::from_file(&path).error_context("Failed to create file target sender.")?,
36+
None => TargetSender::from_config(&config).error_context("Failed to create target sender.")?,
37+
};
2838

2939
Ok(Self { config, corpus, sender })
3040
}

bin/correctness/millstone/src/main.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#![deny(warnings)]
55
#![deny(missing_docs)]
66

7+
use std::path::PathBuf;
8+
79
use saluki_error::GenericError;
810
use tracing::{error, info};
911
use tracing_subscriber::{filter::LevelFilter, EnvFilter};
@@ -42,16 +44,30 @@ fn main() {
4244
fn run() -> Result<(), GenericError> {
4345
info!("millstone starting...");
4446

45-
// We only accept a single command line argument: the path to the configuration file.
46-
let config_path = match std::env::args().nth(1) {
47+
let args: Vec<String> = std::env::args().collect();
48+
49+
// The first argument is always the path to the configuration file.
50+
let config_path = match args.get(1) {
4751
Some(path) => path,
4852
None => {
49-
error!("Path to the configuration file must be passed as the first (and only) argument to `millstone`.");
53+
error!("Usage: millstone <config-path> [--output-file <path>]");
5054
std::process::exit(1);
5155
}
5256
};
5357

54-
let config = Config::try_from_file(&config_path)?;
55-
let driver = Driver::new(config)?;
58+
// Check for an optional `--output-file` flag that redirects output to a file.
59+
let output_file = args
60+
.iter()
61+
.position(|a| a == "--output-file")
62+
.map(|i| {
63+
args.get(i + 1).unwrap_or_else(|| {
64+
error!("--output-file requires a file path argument.");
65+
std::process::exit(1);
66+
})
67+
})
68+
.map(PathBuf::from);
69+
70+
let config = Config::try_from_file(config_path)?;
71+
let driver = Driver::new(config, output_file)?;
5672
driver.run()
5773
}

bin/correctness/millstone/src/target.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use std::{
2+
fs::File,
23
io::Write as _,
34
net::{Ipv4Addr, TcpStream, UdpSocket},
45
os::unix::net::{UnixDatagram, UnixStream},
6+
path::Path,
57
};
68

79
use prost::bytes::Bytes;
@@ -16,6 +18,7 @@ enum TargetBackend {
1618
UnixDatagram(UnixDatagram),
1719
Unix(UnixStream),
1820
Grpc(GrpcBackend),
21+
File(File),
1922
}
2023

2124
struct GrpcBackend {
@@ -31,6 +34,20 @@ pub struct TargetSender {
3134
}
3235

3336
impl TargetSender {
37+
/// Creates a new `TargetSender` that writes to a file.
38+
///
39+
/// # Errors
40+
///
41+
/// If an error occurs while creating the file, it will be returned.
42+
pub fn from_file(path: &Path) -> Result<Self, GenericError> {
43+
let file =
44+
File::create(path).with_error_context(|| format!("Failed to create output file '{}'.", path.display()))?;
45+
Ok(Self {
46+
backend: TargetBackend::File(file),
47+
runtime: None,
48+
})
49+
}
50+
3451
/// Creates a new `TargetSender` based on the given configuration.
3552
///
3653
/// # Errors
@@ -98,6 +115,7 @@ impl TargetSender {
98115
send_grpc_payload(runtime, channel, &service_method_path, payload)?;
99116
payload.len()
100117
}
118+
TargetBackend::File(file) => file.write_all(payload).map(|_| payload.len())?,
101119
};
102120

103121
Ok(n)

test/correctness/dsd-origin-detection/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ datadog_intake:
66
image: saluki-images/datadog-intake:latest
77
config_path: ../datadog-intake.yaml
88
baseline:
9-
image: saluki-images/datadog-agent:testing-devel
9+
image: saluki-images/datadog-agent:testing-release
1010
files:
1111
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1212
additional_env_vars:
1313
- DD_API_KEY=correctness-test
1414
comparison:
15-
image: saluki-images/datadog-agent:testing-devel
15+
image: saluki-images/datadog-agent:testing-release
1616
files:
1717
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1818
additional_env_vars:

test/correctness/dsd-plain/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ datadog_intake:
66
image: saluki-images/datadog-intake:latest
77
config_path: ../datadog-intake.yaml
88
baseline:
9-
image: saluki-images/datadog-agent:testing-devel
9+
image: saluki-images/datadog-agent:testing-release
1010
files:
1111
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1212
additional_env_vars:
1313
- DD_API_KEY=correctness-test
1414
comparison:
15-
image: saluki-images/datadog-agent:testing-devel
15+
image: saluki-images/datadog-agent:testing-release
1616
files:
1717
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1818
additional_env_vars:

test/correctness/otlp-metrics/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ datadog_intake:
66
image: saluki-images/datadog-intake:latest
77
config_path: ../datadog-intake.yaml
88
baseline:
9-
image: saluki-images/datadog-agent:testing-devel
9+
image: saluki-images/datadog-agent:testing-release
1010
files:
1111
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1212
additional_env_vars:
1313
- DD_API_KEY=correctness-test
1414
comparison:
15-
image: saluki-images/datadog-agent:testing-devel
15+
image: saluki-images/datadog-agent:testing-release
1616
files:
1717
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1818
additional_env_vars:

test/correctness/otlp-traces/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ datadog_intake:
66
image: saluki-images/datadog-intake:latest
77
config_path: ../datadog-intake.yaml
88
baseline:
9-
image: saluki-images/datadog-agent:testing-devel
9+
image: saluki-images/datadog-agent:testing-release
1010
files:
1111
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1212
additional_env_vars:
1313
- DD_API_KEY=correctness-test
1414
comparison:
15-
image: saluki-images/datadog-agent:testing-devel
15+
image: saluki-images/datadog-agent:testing-release
1616
files:
1717
- datadog.yaml:/etc/datadog-agent/datadog.yaml
1818
additional_env_vars:

0 commit comments

Comments
 (0)