Skip to content

Commit 06e7f83

Browse files
tobioCopilot
andauthored
Extract integration policy test config (#1443)
* Extract integration policy test config * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Revert timeput -> timeout --------- Co-authored-by: Copilot <[email protected]>
1 parent 8f45626 commit 06e7f83

File tree

10 files changed

+901
-364
lines changed

10 files changed

+901
-364
lines changed

internal/fleet/integration_policy/acc_test.go

Lines changed: 78 additions & 364 deletions
Large diffs are not rendered by default.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
variable "policy_name" {
2+
description = "The integration policy name"
3+
type = string
4+
}
5+
6+
variable "integration_name" {
7+
description = "The integration name"
8+
type = string
9+
default = "tcp"
10+
}
11+
12+
variable "integration_version" {
13+
description = "The integration version"
14+
type = string
15+
default = "1.16.0"
16+
}
17+
18+
provider "elasticstack" {
19+
elasticsearch {}
20+
kibana {}
21+
}
22+
23+
resource "elasticstack_fleet_integration" "test_policy" {
24+
name = var.integration_name
25+
version = var.integration_version
26+
force = true
27+
}
28+
29+
resource "elasticstack_fleet_agent_policy" "test_policy" {
30+
name = "${var.policy_name} Agent Policy"
31+
namespace = "default"
32+
description = "IntegrationPolicyTest Agent Policy"
33+
monitor_logs = true
34+
monitor_metrics = true
35+
skip_destroy = false
36+
}
37+
38+
data "elasticstack_fleet_enrollment_tokens" "test_policy" {
39+
policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
40+
}
41+
42+
resource "elasticstack_fleet_integration_policy" "test_policy" {
43+
name = var.policy_name
44+
namespace = "default"
45+
description = "IntegrationPolicyTest Policy"
46+
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
47+
integration_name = elasticstack_fleet_integration.test_policy.name
48+
integration_version = elasticstack_fleet_integration.test_policy.version
49+
50+
input {
51+
input_id = "tcp-tcp"
52+
enabled = true
53+
streams_json = jsonencode({
54+
"tcp.generic" : {
55+
"enabled" : true
56+
"vars" : {
57+
"listen_address" : "localhost"
58+
"listen_port" : 8080
59+
"data_stream.dataset" : "tcp.generic"
60+
"tags" : []
61+
"syslog_options" : "field: message"
62+
"ssl" : ""
63+
"custom" : ""
64+
}
65+
}
66+
})
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
variable "policy_name" {
2+
description = "The integration policy name"
3+
type = string
4+
}
5+
6+
variable "integration_name" {
7+
description = "The integration name"
8+
type = string
9+
default = "tcp"
10+
}
11+
12+
variable "integration_version" {
13+
description = "The integration version"
14+
type = string
15+
default = "1.16.0"
16+
}
17+
18+
provider "elasticstack" {
19+
elasticsearch {}
20+
kibana {}
21+
}
22+
23+
resource "elasticstack_fleet_integration" "test_policy" {
24+
name = var.integration_name
25+
version = var.integration_version
26+
force = true
27+
}
28+
29+
resource "elasticstack_fleet_agent_policy" "test_policy" {
30+
name = "${var.policy_name} Agent Policy"
31+
namespace = "default"
32+
description = "IntegrationPolicyTest Agent Policy"
33+
monitor_logs = true
34+
monitor_metrics = true
35+
skip_destroy = false
36+
}
37+
38+
data "elasticstack_fleet_enrollment_tokens" "test_policy" {
39+
policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
40+
}
41+
42+
resource "elasticstack_fleet_integration_policy" "test_policy" {
43+
name = var.policy_name
44+
namespace = "default"
45+
description = "Updated Integration Policy"
46+
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
47+
integration_name = elasticstack_fleet_integration.test_policy.name
48+
integration_version = elasticstack_fleet_integration.test_policy.version
49+
50+
input {
51+
input_id = "tcp-tcp"
52+
enabled = false
53+
streams_json = jsonencode({
54+
"tcp.generic" : {
55+
"enabled" : false
56+
"vars" : {
57+
"listen_address" : "localhost"
58+
"listen_port" : 8085
59+
"data_stream.dataset" : "tcp.generic"
60+
"tags" : []
61+
"syslog_options" : "field: message"
62+
"ssl" : ""
63+
"custom" : ""
64+
}
65+
}
66+
})
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
variable "policy_name" {
2+
description = "The integration policy name"
3+
type = string
4+
}
5+
6+
variable "integration_name" {
7+
description = "The integration name"
8+
type = string
9+
default = "tcp"
10+
}
11+
12+
variable "integration_version" {
13+
description = "The integration version"
14+
type = string
15+
default = "1.16.0"
16+
}
17+
18+
provider "elasticstack" {
19+
elasticsearch {}
20+
kibana {}
21+
}
22+
23+
resource "elasticstack_fleet_integration" "test_policy" {
24+
name = var.integration_name
25+
version = var.integration_version
26+
force = true
27+
}
28+
29+
resource "elasticstack_fleet_agent_policy" "test_policy_1" {
30+
name = "${var.policy_name} Agent Policy 1"
31+
namespace = "default"
32+
description = "IntegrationPolicyTest Agent Policy 1"
33+
monitor_logs = true
34+
monitor_metrics = true
35+
skip_destroy = false
36+
}
37+
38+
resource "elasticstack_fleet_agent_policy" "test_policy_2" {
39+
name = "${var.policy_name} Agent Policy 2"
40+
namespace = "default"
41+
description = "IntegrationPolicyTest Agent Policy 2"
42+
monitor_logs = true
43+
monitor_metrics = true
44+
skip_destroy = false
45+
}
46+
47+
resource "elasticstack_fleet_integration_policy" "test_policy" {
48+
name = var.policy_name
49+
namespace = "default"
50+
description = "IntegrationPolicyTest Policy"
51+
agent_policy_ids = [
52+
elasticstack_fleet_agent_policy.test_policy_1.policy_id,
53+
elasticstack_fleet_agent_policy.test_policy_2.policy_id
54+
]
55+
integration_name = elasticstack_fleet_integration.test_policy.name
56+
integration_version = elasticstack_fleet_integration.test_policy.version
57+
58+
input {
59+
input_id = "tcp-tcp"
60+
streams_json = jsonencode({
61+
"tcp.generic" : {
62+
"enabled" : true
63+
"vars" : {
64+
"listen_address" : "localhost"
65+
"listen_port" : 8080
66+
"data_stream.dataset" : "tcp.generic"
67+
"tags" : []
68+
"syslog_options" : "field: message"
69+
"ssl" : ""
70+
"custom" : ""
71+
}
72+
}
73+
})
74+
}
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
variable "policy_name" {
2+
description = "The integration policy name"
3+
type = string
4+
}
5+
6+
variable "secret_key" {
7+
description = "The secret key for access"
8+
type = string
9+
}
10+
11+
variable "integration_name" {
12+
description = "The integration name"
13+
type = string
14+
default = "sql"
15+
}
16+
17+
variable "integration_version" {
18+
description = "The integration version"
19+
type = string
20+
default = "1.1.0"
21+
}
22+
23+
provider "elasticstack" {
24+
elasticsearch {}
25+
kibana {}
26+
}
27+
28+
resource "elasticstack_fleet_integration" "test_policy" {
29+
name = var.integration_name
30+
version = var.integration_version
31+
force = true
32+
}
33+
34+
resource "elasticstack_fleet_agent_policy" "test_policy" {
35+
name = "${var.policy_name} Agent Policy"
36+
namespace = "default"
37+
description = "IntegrationPolicyTest Agent Policy"
38+
monitor_logs = true
39+
monitor_metrics = true
40+
skip_destroy = false
41+
}
42+
43+
data "elasticstack_fleet_enrollment_tokens" "test_policy" {
44+
policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
45+
}
46+
47+
resource "elasticstack_fleet_integration_policy" "test_policy" {
48+
name = var.policy_name
49+
namespace = "default"
50+
description = "SQL Integration Policy"
51+
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
52+
integration_name = elasticstack_fleet_integration.test_policy.name
53+
integration_version = elasticstack_fleet_integration.test_policy.version
54+
55+
input {
56+
input_id = "sql-sql/metrics"
57+
enabled = true
58+
streams_json = jsonencode({
59+
"sql.sql" : {
60+
"enabled" : true,
61+
"vars" : {
62+
"hosts" : ["root:test@tcp(127.0.0.1:3306)/"],
63+
"period" : "1m",
64+
"driver" : "mysql",
65+
"sql_queries" : "- query: SHOW GLOBAL STATUS LIKE 'Innodb_system%'\n response_format: variables\n \n",
66+
"merge_results" : false,
67+
"ssl" : "",
68+
"data_stream.dataset" : "sql",
69+
"processors" : ""
70+
}
71+
}
72+
})
73+
}
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
variable "policy_name" {
2+
description = "The integration policy name"
3+
type = string
4+
}
5+
6+
variable "secret_key" {
7+
description = "The secret key for access"
8+
type = string
9+
}
10+
11+
variable "integration_name" {
12+
description = "The integration name"
13+
type = string
14+
default = "sql"
15+
}
16+
17+
variable "integration_version" {
18+
description = "The integration version"
19+
type = string
20+
default = "1.1.0"
21+
}
22+
23+
provider "elasticstack" {
24+
elasticsearch {}
25+
kibana {}
26+
}
27+
28+
resource "elasticstack_fleet_integration" "test_policy" {
29+
name = var.integration_name
30+
version = var.integration_version
31+
force = true
32+
}
33+
34+
resource "elasticstack_fleet_agent_policy" "test_policy" {
35+
name = "${var.policy_name} Agent Policy"
36+
namespace = "default"
37+
description = "IntegrationPolicyTest Agent Policy"
38+
monitor_logs = true
39+
monitor_metrics = true
40+
skip_destroy = false
41+
}
42+
43+
data "elasticstack_fleet_enrollment_tokens" "test_policy" {
44+
policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
45+
}
46+
47+
resource "elasticstack_fleet_integration_policy" "test_policy" {
48+
name = var.policy_name
49+
namespace = "default"
50+
description = "SQL Integration Policy"
51+
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
52+
integration_name = elasticstack_fleet_integration.test_policy.name
53+
integration_version = elasticstack_fleet_integration.test_policy.version
54+
55+
input {
56+
input_id = "sql-sql/metrics"
57+
enabled = true
58+
streams_json = jsonencode({
59+
"sql.sql" : {
60+
"enabled" : true,
61+
"vars" : {
62+
"hosts" : ["root:test@tcp(127.0.0.1:3306)/"],
63+
"period" : "1m",
64+
"driver" : "mysql",
65+
"sql_queries" : "- query: SHOW GLOBAL STATUS LIKE 'Innodb_system%'\n response_format: variables\n \n",
66+
"merge_results" : false,
67+
"ssl" : "",
68+
"data_stream.dataset" : "sql",
69+
"processors" : ""
70+
}
71+
}
72+
})
73+
}
74+
}

0 commit comments

Comments
 (0)