Skip to content

Commit 8325eef

Browse files
feat(ci/cd): adding a e2e with infra agent
1 parent 5d895d3 commit 8325eef

File tree

11 files changed

+37
-51
lines changed

11 files changed

+37
-51
lines changed

test/e2e-runner/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod test;
1010

1111
/// Arguments to be set for every test that needs Agent Control installation
1212
#[derive(Default, Debug, Clone, clap::Parser)]
13-
pub struct InstallArgs {
13+
pub struct Args {
1414
/// Folder where '.deb' packages are stored
1515
#[arg(long)]
1616
pub artifacts_package_dir: Option<PathBuf>,
@@ -62,7 +62,7 @@ pub struct InstallArgs {
6262

6363
/// Data to set up installation
6464
pub struct RecipeData {
65-
pub args: InstallArgs,
65+
pub args: Args,
6666
pub fleet_id: String,
6767
pub fleet_enabled: String,
6868
pub recipe_list: String,

test/e2e-runner/src/common/nrql.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::common::InstallArgs;
1+
use crate::common::Args;
22
use crate::common::test::TestResult;
33
use reqwest::blocking::Client;
44
use serde::Serialize;
@@ -58,7 +58,7 @@ impl Region {
5858
/// * `Ok(Vec<Value>)` - The NRQL query results on success
5959
/// * `Err` - Error if the query fails, returns errors, or has no results
6060
pub fn check_query_results_are_not_empty(
61-
install_args: &InstallArgs,
61+
install_args: &Args,
6262
nrql_query: &str,
6363
) -> TestResult<Vec<Value>> {
6464
let client = Client::builder().timeout(CLIENT_TIMEOUT).build()?;

test/e2e-runner/src/linux/scenarios/ebpf_agent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::common::InstallArgs;
1+
use crate::common::Args;
22
use crate::common::RecipeData;
33
use crate::{
44
common::{config, logs::ShowLogsOnDrop, nrql, test::retry},
@@ -7,7 +7,7 @@ use crate::{
77
use std::time::Duration;
88
use tracing::info;
99

10-
pub fn test_ebpf_agent(args: InstallArgs) {
10+
pub fn test_ebpf_agent(args: Args) {
1111
let recipe_data = RecipeData {
1212
args,
1313
monitoring_source: "infra-agent".to_string(),

test/e2e-runner/src/linux/scenarios/infra_agent.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::common::{InstallArgs, RecipeData};
1+
use crate::common::{Args, RecipeData};
22
use crate::{
33
common::{config, logs::ShowLogsOnDrop, nrql, test::retry},
44
linux::{self, install::install_agent_control_from_recipe},
55
};
66
use std::time::Duration;
77
use tracing::info;
88

9-
pub fn test_installation_with_infra_agent(args: InstallArgs) {
9+
pub fn test_installation_with_infra_agent(args: Args) {
1010
let recipe_data = RecipeData {
1111
args,
1212
monitoring_source: "infra-agent".to_string(),
@@ -29,9 +29,7 @@ pub fn test_installation_with_infra_agent(args: InstallArgs) {
2929
info!(nrql = nrql_query, "Checking results of NRQL");
3030
let retries = 120;
3131
retry(retries, Duration::from_secs(10), "nrql assertion", || {
32-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
33-
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
34-
})
32+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
3533
})
3634
.unwrap_or_else(|err| {
3735
panic!("query '{nrql_query}' failed after {retries} retries: {err}");

test/e2e-runner/src/linux/scenarios/migration.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::common::{InstallArgs, RecipeData};
1+
use crate::common::{Args, RecipeData};
22
use crate::{
33
common::{config, nrql, test::retry},
44
linux::{self, bash::exec_bash_command, install::install_agent_control_from_recipe, service},
55
};
66
use std::{fs, time::Duration};
77
use tracing::{debug, info};
88

9-
pub fn test_migration(args: InstallArgs) {
9+
pub fn test_migration(args: Args) {
1010
let test_id = format!(
1111
"onhost-e2e-infra-agent_{}",
1212
chrono::Local::now().format("%Y-%m-%d_%H-%M-%S")
@@ -22,9 +22,7 @@ pub fn test_migration(args: InstallArgs) {
2222
info!(nrql = nrql_query, "Checking results of NRQL");
2323
let retries = 12;
2424
retry(retries, Duration::from_secs(10), "nrql assertion", || {
25-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
26-
nrql::check_query_results_are_not_empty(&args, &nrql_query)
27-
})
25+
nrql::check_query_results_are_not_empty(&args, &nrql_query)
2826
})
2927
.unwrap_or_else(|err| {
3028
panic!("query '{nrql_query}' failed after {retries} retries: {err}");
@@ -54,16 +52,14 @@ pub fn test_migration(args: InstallArgs) {
5452
info!(nrql = nrql_query, "Checking results of NRQL");
5553
let retries = 12;
5654
retry(retries, Duration::from_secs(10), "nrql assertion", || {
57-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
58-
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
59-
})
55+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
6056
})
6157
.unwrap_or_else(|err| {
6258
panic!("query '{nrql_query}' failed after {retries} retries: {err}");
6359
});
6460
}
6561

66-
fn install_and_setup_infra_agent_with_mysql(args: &InstallArgs, test_id: &str) {
62+
fn install_and_setup_infra_agent_with_mysql(args: &Args, test_id: &str) {
6763
// Install infra agent
6864
let install_command = format!(
6965
r#"

test/e2e-runner/src/linux/scenarios/nrdot_agent.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::common::{InstallArgs, RecipeData};
1+
use crate::common::{Args, RecipeData};
22
use crate::{
33
common::{config, logs::ShowLogsOnDrop, nrql, test::retry},
44
linux::{self, install::install_agent_control_from_recipe},
55
};
66
use std::time::Duration;
77
use tracing::info;
88

9-
pub fn test_nrdot_agent(args: InstallArgs) {
9+
pub fn test_nrdot_agent(args: Args) {
1010
let recipe_data = RecipeData {
1111
args,
1212
monitoring_source: "otel".to_string(),
@@ -32,9 +32,7 @@ pub fn test_nrdot_agent(args: InstallArgs) {
3232
info!(nrql = nrql_query, "Checking results of NRQL");
3333
let retries = 120;
3434
retry(retries, Duration::from_secs(10), "nrql assertion", || {
35-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
36-
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
37-
})
35+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
3836
})
3937
.unwrap_or_else(|err| {
4038
panic!("query '{nrql_query}' failed after {retries} retries: {err}");

test/e2e-runner/src/linux/scenarios/proxy.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::common::{InstallArgs, RecipeData};
1+
use crate::common::{Args, RecipeData};
22
use crate::{
33
common::{config, logs::ShowLogsOnDrop, nrql, test::retry},
44
linux::{self, bash::exec_bash_command, install::install_agent_control_from_recipe},
@@ -28,7 +28,7 @@ const EXPECTED_DOMAINS: &[&str] = &[
2828
"infra-api.newrelic.com",
2929
];
3030

31-
pub fn test_agent_control_proxy(args: InstallArgs) {
31+
pub fn test_agent_control_proxy(args: Args) {
3232
info!("Setting up mitmproxy container");
3333
setup_mitmproxy();
3434

@@ -60,9 +60,7 @@ pub fn test_agent_control_proxy(args: InstallArgs) {
6060
info!(nrql = nrql_query, "Checking results of NRQL");
6161
let retries = 120;
6262
retry(retries, Duration::from_secs(10), "nrql assertion", || {
63-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
64-
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
65-
})
63+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
6664
})
6765
.unwrap_or_else(|err| {
6866
panic!("query '{nrql_query}' failed after {retries} retries: {err}");

test/e2e-runner/src/linux/scenarios/remote_config.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::common::{InstallArgs, RecipeData};
1+
use crate::common::{Args, RecipeData};
22
use crate::{
33
common::{config, logs::ShowLogsOnDrop, nrql, test::retry},
44
linux::{self, install::install_agent_control_from_recipe},
@@ -11,7 +11,7 @@ const FLEET_ID: &str = "NjQyNTg2NXxOR0VQfEZMRUVUfDAxOTkyOGQyLTg3OTAtNzJlNC05ODgw
1111

1212
const ENV_VARS_FILE: &str = "/etc/newrelic-agent-control/environment_variables.yaml";
1313

14-
pub fn test_remote_config_is_applied(args: InstallArgs) {
14+
pub fn test_remote_config_is_applied(args: Args) {
1515
let recipe_data = RecipeData {
1616
args,
1717
monitoring_source: "infra-agent".to_string(),
@@ -55,9 +55,7 @@ config_agent:
5555
info!(nrql = nrql_query, "Checking results of NRQL");
5656
let retries = 60;
5757
retry(retries, Duration::from_secs(5), "nrql assertion", || {
58-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
59-
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
60-
})
58+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
6159
})
6260
.unwrap_or_else(|err| {
6361
panic!("query '{nrql_query}' failed after {retries} retries: {err}");
@@ -71,9 +69,7 @@ config_agent:
7169
info!(nrql = nrql_query, "Checking results of NRQL");
7270
let retries = 120;
7371
retry(retries, Duration::from_secs(10), "nrql assertion", || {
74-
retry(retries, Duration::from_secs(10), "nrql assertion", || {
75-
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
76-
})
72+
nrql::check_query_results_are_not_empty(&recipe_data.args, &nrql_query)
7773
})
7874
.unwrap_or_else(|err| {
7975
panic!("query '{nrql_query}' failed after {retries} retries: {err}");

test/e2e-runner/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod common;
22
mod linux;
33
mod windows;
44

5-
use crate::common::InstallArgs;
5+
use crate::common::Args;
66
use clap::Parser;
77
use std::process;
88
use tracing_subscriber::EnvFilter;
@@ -22,27 +22,27 @@ fn main() {
2222
#[derive(Debug, clap::Subcommand)]
2323
enum LinuxScenarios {
2424
/// Local installation of Agent Control with Infrastructure Agent. It checks that the infra-agent eventually reports data.
25-
InfraAgent(InstallArgs),
25+
InfraAgent(Args),
2626
/// Local installation of Agent Control with eBPF agent. Uses the infra agent to generate traffic and checks that
2727
/// the eBPF agent reports data.
28-
EBPFAgent(InstallArgs),
28+
EBPFAgent(Args),
2929
/// Migration of an Infrastructure Agent installation. It spawns a mysql docker service, reports mysql metrics
3030
/// through the infra-agent and checks that metrics keep reporting after migration.
31-
Migration(InstallArgs),
31+
Migration(Args),
3232
/// Local installation of Agent Control with NRDot. It checks that nr-dot eventually reports data.
33-
NrdotAgent(InstallArgs),
33+
NrdotAgent(Args),
3434
/// Checks that remote configuration for a sub-agent has been applied.
35-
RemoteConfig(InstallArgs),
35+
RemoteConfig(Args),
3636
/// Checks that the Agent Control proxy support works as expected. It uses mitproxy as a docker service.
37-
Proxy(InstallArgs),
37+
Proxy(Args),
3838
}
3939

4040
#[derive(Debug, clap::Subcommand)]
4141
enum WindowsScenarios {
4242
/// Simple installation of Agent Control on Windows
43-
Install(InstallArgs),
43+
Install(Args),
4444
/// Simple installation of Agent Control on Windows with an Infrastructure Agent
45-
InfraAgent(InstallArgs),
45+
InfraAgent(Args),
4646
}
4747

4848
#[derive(Parser)]

test/e2e-runner/src/windows/scenarios/installation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::common::logs::ShowLogsOnDrop;
22
use crate::common::test::retry;
3-
use crate::common::{InstallArgs, RecipeData, config};
3+
use crate::common::{Args, RecipeData, config};
44
use crate::windows;
55
use crate::windows::cleanup::CleanAcOnDrop;
66
use crate::windows::install::install_agent_control_from_recipe;
@@ -12,7 +12,7 @@ const DEFAULT_STATUS_PORT: u16 = 51200;
1212
const SERVICE_NAME: &str = "newrelic-agent-control";
1313

1414
/// Runs a complete Windows E2E installation test.
15-
pub fn test_installation(args: InstallArgs) {
15+
pub fn test_installation(args: Args) {
1616
let recipe_data = RecipeData {
1717
args,
1818
..Default::default()

0 commit comments

Comments
 (0)