Skip to content

Commit 1295367

Browse files
authored
fix: rollback test changes and branches to be able to merge restructure onhost changes (#1850)
1 parent 337f3e8 commit 1295367

File tree

7 files changed

+364
-368
lines changed

7 files changed

+364
-368
lines changed

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace = os.getenv('NAMESPACE','default')
1212
sa_chart_values_file = os.getenv('SA_CHART_VALUES_FILE','local/agent-control-tilt.yml')
1313
cluster = os.getenv('CLUSTER', "")
1414
# Branch of the helm-charts repo to use.
15-
feature_branch = os.getenv('FEATURE_BRANCH', "change-config-volume-path-for-agent-control")
15+
feature_branch = os.getenv('FEATURE_BRANCH', "master")
1616

1717
# Remote updates are disabled by default in order to avoid accidental downgrades.
1818
enable_ac_remote_update = os.getenv('ENABLE_AC_REMOTE_UPDATE', "false")

agent-control/tests/k8s/Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ helm_resource(
8787
#### build data/charts and upload it to chart museum
8888
### Feature Branch Workaround ###
8989
# Use the branch source to get the chart form a feature branch in the NR helm-charts repo.
90-
feature_branch = os.getenv('FEATURE_BRANCH', "change-config-volume-path-for-agent-control")
90+
feature_branch = os.getenv('FEATURE_BRANCH', "master")
9191

9292
# We're modifying the default image in the charts for different versions because we don't expose the values to be
9393
# modified by the remote_config but we do tests upgrading charts that require image modification

agent-control/tests/k8s/agent_control_cli/installation.rs

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -90,53 +90,52 @@ fn k8s_cli_install_agent_control_installation_with_invalid_image_tag() {
9090
);
9191
assert.failure(); // The installation check should detect that AC workloads cannot be created due to invalid image
9292
}
93-
// /// TODO: Re-enable this test after PR #1752 (this repo) and helm-charts PR #1965 are merged to main.
94-
// #[test]
95-
// #[ignore = "needs k8s cluster"]
96-
// fn k8s_cli_install_agent_control_installation_failed_upgrade() {
97-
// let mut k8s_env = block_on(K8sEnv::new());
98-
// let ac_namespace = block_on(k8s_env.test_namespace());
99-
// let subagents_namespace = block_on(k8s_env.test_namespace());
100-
// let opamp_server = FakeServer::start_new();
101-
//
102-
// create_simple_values_secret(
103-
// k8s_env.client.clone(),
104-
// &ac_namespace,
105-
// &subagents_namespace,
106-
// "test-secret",
107-
// opamp_server.endpoint().as_str(),
108-
// "values.yaml",
109-
// );
110-
//
111-
// let release_name = "install-ac-installation-failed-upgrade";
112-
// let mut cmd = ac_install_cmd(
113-
// &ac_namespace,
114-
// CHART_VERSION_LATEST_RELEASE,
115-
// release_name,
116-
// "test-secret=values.yaml",
117-
// );
118-
// let assert = cmd.assert();
119-
// print_cli_output(&assert);
120-
// assert.success(); // Install successfully
121-
//
122-
// // The chart version does not exist
123-
// let mut cmd = ac_install_cmd(
124-
// &ac_namespace,
125-
// MISSING_VERSION,
126-
// release_name,
127-
// "test-secret=values.yaml",
128-
// );
129-
// let assert = cmd.assert();
130-
// print_cli_output(&assert);
131-
// assert_stdout_contains(
132-
// &assert,
133-
// format!(
134-
// "no 'agent-control-deployment' chart with version matching '{MISSING_VERSION}' found"
135-
// )
136-
// .as_str(),
137-
// );
138-
// assert.failure(); // The installation check should detect that the upgrade failed
139-
// }
93+
#[test]
94+
#[ignore = "needs k8s cluster"]
95+
fn k8s_cli_install_agent_control_installation_failed_upgrade() {
96+
let mut k8s_env = block_on(K8sEnv::new());
97+
let ac_namespace = block_on(k8s_env.test_namespace());
98+
let subagents_namespace = block_on(k8s_env.test_namespace());
99+
let opamp_server = FakeServer::start_new();
100+
101+
create_simple_values_secret(
102+
k8s_env.client.clone(),
103+
&ac_namespace,
104+
&subagents_namespace,
105+
"test-secret",
106+
opamp_server.endpoint().as_str(),
107+
"values.yaml",
108+
);
109+
110+
let release_name = "install-ac-installation-failed-upgrade";
111+
let mut cmd = ac_install_cmd(
112+
&ac_namespace,
113+
CHART_VERSION_LATEST_RELEASE,
114+
release_name,
115+
"test-secret=values.yaml",
116+
);
117+
let assert = cmd.assert();
118+
print_cli_output(&assert);
119+
assert.success(); // Install successfully
120+
121+
// The chart version does not exist
122+
let mut cmd = ac_install_cmd(
123+
&ac_namespace,
124+
MISSING_VERSION,
125+
release_name,
126+
"test-secret=values.yaml",
127+
);
128+
let assert = cmd.assert();
129+
print_cli_output(&assert);
130+
assert_stdout_contains(
131+
&assert,
132+
format!(
133+
"no 'agent-control-deployment' chart with version matching '{MISSING_VERSION}' found"
134+
)
135+
.as_str(),
136+
);
137+
assert.failure(); // The installation check should detect that the upgrade failed
138+
}
140139

141140
/// Builds an installation command for testing purposes with a curated set of defaults and the provided arguments.
142141
pub fn ac_install_cmd(

agent-control/tests/k8s/agent_control_cli/uninstallation.rs

Lines changed: 97 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,104 @@
1-
// use crate::common::retry::retry;
1+
use crate::common::retry::retry;
22
use crate::common::runtime::block_on;
3-
// use crate::k8s::agent_control_cli::installation::ac_install_cmd;
3+
use crate::k8s::agent_control_cli::installation::ac_install_cmd;
44
use crate::k8s::tools::cmd::print_cli_output;
5-
// use crate::k8s::tools::k8s_api::create_values_secret;
5+
use crate::k8s::tools::k8s_api::create_values_secret;
66
use crate::k8s::tools::k8s_env::K8sEnv;
7-
// use crate::k8s::tools::local_chart::agent_control_deploymet::CHART_VERSION_LATEST_RELEASE;
8-
// use crate::k8s::tools::logs::{AC_LABEL_SELECTOR, print_pod_logs};
7+
use crate::k8s::tools::local_chart::agent_control_deploymet::CHART_VERSION_LATEST_RELEASE;
8+
use crate::k8s::tools::logs::{AC_LABEL_SELECTOR, print_pod_logs};
99
use assert_cmd::{Command, cargo_bin_cmd};
10-
// use k8s_openapi::api::apps::v1::Deployment;
11-
// use k8s_openapi::api::core::v1::{ConfigMap, Secret};
12-
// use kube::Api;
13-
// use std::time::Duration;
14-
// /// TODO: Re-enable this test after PR #1752 (this repo) and helm-charts PR #1965 are merged to main.
15-
// #[test]
16-
// #[ignore = "needs k8s cluster"]
17-
// // This test can break if the chart introduces any breaking changes.
18-
// // If this situation occurs, we will need to disable the test or use
19-
// // a similar workaround than the one we use in the tiltfile.
20-
// fn k8s_cli_install_agent_control_installation_and_uninstallation() {
21-
// let mut k8s_env = block_on(K8sEnv::new());
22-
// let ac_namespace = block_on(k8s_env.test_namespace());
23-
// let subagents_namespace = block_on(k8s_env.test_namespace());
24-
//
25-
// let values = serde_json::json!({
26-
// "nameOverride": "",
27-
// "cleanupManagedResources": false,
28-
// "subAgentsNamespace": subagents_namespace,
29-
// "config": {
30-
// "fleet_control": {
31-
// "enabled": false,
32-
// },
33-
// "agents": {
34-
// "nrdot":{
35-
// "agent_type" : "newrelic/io.opentelemetry.collector:0.1.0",
36-
// },
37-
// }
38-
// },
39-
// "agentsConfig": {
40-
// "nrdot":{
41-
// "chart_version" : "*"
42-
// },
43-
// },
44-
// "global": {
45-
// "cluster": "test-cluster",
46-
// "licenseKey": "thisisafakelicensekey",
47-
// },
48-
// })
49-
// .to_string();
50-
// create_values_secret(
51-
// k8s_env.client.clone(),
52-
// &ac_namespace,
53-
// "test-secret",
54-
// "values.yaml",
55-
// values,
56-
// );
57-
//
58-
// print_pod_logs(k8s_env.client.clone(), &ac_namespace, AC_LABEL_SELECTOR);
59-
//
60-
// let release_name = "install-ac-installation-and-uninstallation";
61-
// let mut cmd = ac_install_cmd(
62-
// &ac_namespace,
63-
// CHART_VERSION_LATEST_RELEASE,
64-
// release_name,
65-
// "test-secret=values.yaml",
66-
// );
67-
// let assert = cmd.assert();
68-
// print_cli_output(&assert);
69-
// assert.success();
70-
//
71-
// let deployments: Api<Deployment> = Api::namespaced(k8s_env.client.clone(), &ac_namespace);
72-
// let config_maps: Api<ConfigMap> = Api::namespaced(k8s_env.client.clone(), &ac_namespace);
73-
// let secrets: Api<Secret> = Api::namespaced(k8s_env.client.clone(), &ac_namespace);
74-
//
75-
// let deployment_name = format!("{}-agent-control-deploy", release_name);
76-
// retry(10, Duration::from_secs(1), || {
77-
// // We set "nameOverride" in the secret values to force the deployment name
78-
// // to be equal to the release name. This avoids breaking the test if the
79-
// // default value changes in the chart.
80-
// let _ = block_on(deployments.get(&deployment_name))?;
81-
// Ok(())
82-
// });
83-
// retry(10, Duration::from_secs(1), || {
84-
// let _ = block_on(config_maps.get("local-data-nrdot"))?;
85-
// Ok(())
86-
// });
87-
// retry(10, Duration::from_secs(1), || {
88-
// let _ = block_on(secrets.get("values-nrdot"))?;
89-
// Ok(())
90-
// });
91-
//
92-
// let mut cmd = ac_uninstall_cmd(&ac_namespace, &subagents_namespace, release_name);
93-
// let assert = cmd.assert();
94-
// print_cli_output(&assert);
95-
// assert.success();
96-
//
97-
// let _ =
98-
// block_on(deployments.get(&deployment_name)).expect_err("AC deployment should be deleted");
99-
// let _ = block_on(config_maps.get("local-data-nrdot"))
100-
// .expect_err("SubAgent config_map should be deleted");
101-
// let _ = block_on(secrets.get("values-nrdot")).expect_err("SubAgent secret should be deleted");
102-
// }
10+
use k8s_openapi::api::apps::v1::Deployment;
11+
use k8s_openapi::api::core::v1::{ConfigMap, Secret};
12+
use kube::Api;
13+
use std::time::Duration;
14+
#[test]
15+
#[ignore = "needs k8s cluster"]
16+
// This test can break if the chart introduces any breaking changes.
17+
// If this situation occurs, we will need to disable the test or use
18+
// a similar workaround than the one we use in the tiltfile.
19+
fn k8s_cli_install_agent_control_installation_and_uninstallation() {
20+
let mut k8s_env = block_on(K8sEnv::new());
21+
let ac_namespace = block_on(k8s_env.test_namespace());
22+
let subagents_namespace = block_on(k8s_env.test_namespace());
23+
24+
let values = serde_json::json!({
25+
"nameOverride": "",
26+
"cleanupManagedResources": false,
27+
"subAgentsNamespace": subagents_namespace,
28+
"config": {
29+
"fleet_control": {
30+
"enabled": false,
31+
},
32+
"agents": {
33+
"nrdot":{
34+
"agent_type" : "newrelic/io.opentelemetry.collector:0.1.0",
35+
},
36+
}
37+
},
38+
"agentsConfig": {
39+
"nrdot":{
40+
"chart_version" : "*"
41+
},
42+
},
43+
"global": {
44+
"cluster": "test-cluster",
45+
"licenseKey": "thisisafakelicensekey",
46+
},
47+
})
48+
.to_string();
49+
create_values_secret(
50+
k8s_env.client.clone(),
51+
&ac_namespace,
52+
"test-secret",
53+
"values.yaml",
54+
values,
55+
);
56+
57+
print_pod_logs(k8s_env.client.clone(), &ac_namespace, AC_LABEL_SELECTOR);
58+
59+
let release_name = "install-ac-installation-and-uninstallation";
60+
let mut cmd = ac_install_cmd(
61+
&ac_namespace,
62+
CHART_VERSION_LATEST_RELEASE,
63+
release_name,
64+
"test-secret=values.yaml",
65+
);
66+
let assert = cmd.assert();
67+
print_cli_output(&assert);
68+
assert.success();
69+
70+
let deployments: Api<Deployment> = Api::namespaced(k8s_env.client.clone(), &ac_namespace);
71+
let config_maps: Api<ConfigMap> = Api::namespaced(k8s_env.client.clone(), &ac_namespace);
72+
let secrets: Api<Secret> = Api::namespaced(k8s_env.client.clone(), &ac_namespace);
73+
74+
let deployment_name = format!("{}-agent-control-deploy", release_name);
75+
retry(10, Duration::from_secs(1), || {
76+
// We set "nameOverride" in the secret values to force the deployment name
77+
// to be equal to the release name. This avoids breaking the test if the
78+
// default value changes in the chart.
79+
let _ = block_on(deployments.get(&deployment_name))?;
80+
Ok(())
81+
});
82+
retry(10, Duration::from_secs(1), || {
83+
let _ = block_on(config_maps.get("local-data-nrdot"))?;
84+
Ok(())
85+
});
86+
retry(10, Duration::from_secs(1), || {
87+
let _ = block_on(secrets.get("values-nrdot"))?;
88+
Ok(())
89+
});
90+
91+
let mut cmd = ac_uninstall_cmd(&ac_namespace, &subagents_namespace, release_name);
92+
let assert = cmd.assert();
93+
print_cli_output(&assert);
94+
assert.success();
95+
96+
let _ =
97+
block_on(deployments.get(&deployment_name)).expect_err("AC deployment should be deleted");
98+
let _ = block_on(config_maps.get("local-data-nrdot"))
99+
.expect_err("SubAgent config_map should be deleted");
100+
let _ = block_on(secrets.get("values-nrdot")).expect_err("SubAgent secret should be deleted");
101+
}
103102

104103
#[test]
105104
#[ignore = "needs k8s cluster"]

0 commit comments

Comments
 (0)