This repository was archived by the owner on May 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathagent_spec.py
More file actions
91 lines (71 loc) · 2.65 KB
/
Copy pathagent_spec.py
File metadata and controls
91 lines (71 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
from expects import expect, have_key, have_keys
from expects.matchers import _Or
from expects.matchers.built_in import be_empty, contain, be_above_or_equal
from mamba import before, it, description
from sdcclient import SdcClient
from specs import be_successful_api_call
def _mysql_app_check():
return """\
app_checks:
- name: mysql
pattern:
comm: mysqld
conf:
server: 127.0.0.1
user: sysdig-cloud
pass: sysdig-cloud-password
"""
def _debug_enabled():
return """\
log:
console_priority: debug
"""
# See https://docs.sysdig.com/en/agent-auto-config.html for more information
def _agent_configuration():
return {
"files": [
{
"filter": "host.mac = \"08:00:27:de:5b:b9\"",
"content": _mysql_app_check()
},
{
"filter": "*",
"content": _debug_enabled()
}
]
}
with description("Agent", "integration-agent") as self:
with before.all:
self.client = SdcClient(sdc_url=os.getenv("SDC_MONITOR_URL", "https://app.sysdigcloud.com"),
token=os.getenv("SDC_MONITOR_TOKEN"))
with it("is able to retrieve the agent configuration"):
ok, res = self.client.get_agents_config()
expect((ok, res)).to(be_successful_api_call)
expect(res).to(have_key("files", _Or(be_empty, contain(have_key("content")))))
with it("is able to set up the agent configuration"):
ok, res = self.client.set_agents_config(_agent_configuration())
expect((ok, res)).to(be_successful_api_call)
expect(res).to(have_key("files", contain(have_key("content", contain(_mysql_app_check())))))
expect(res).to(have_key("files", contain(have_key("content", contain(_debug_enabled())))))
with it("is able to clean up the agent configuration"):
ok, res = self.client.clear_agents_config()
expect((ok, res)).to(be_successful_api_call)
expect(res).to(have_key("files", be_empty))
with it("is able to retrieve the number of connected agents"):
ok, res = self.client.get_n_connected_agents()
expect((ok, res)).to(be_successful_api_call)
expect(res).to(be_above_or_equal(1))
with it("is able to retrieve the info from the connected agents"):
ok, res = self.client.get_connected_agents()
expect((ok, res)).to(be_successful_api_call)
expect(res).to(contain(have_keys(
"customer",
"machineId",
"hostName",
connected=True,
attributes=have_keys(
"hidden",
"version",
)
)))