Skip to content

Commit

Permalink
tests: fix some CI tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 authored and poiana committed Apr 16, 2024
1 parent eedebfa commit 039a5f5
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_db_program_spawned_process(sinsp, run_containers: dict):
},
{
"container.id": generator_id,
"evt.args": "filename=/bin/ls ",
"evt.args": "filename=/bin/ls",
"evt.category": "process",
"evt.num": SinspField.numeric_field(),
"evt.time": SinspField.numeric_field(),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/test_event_generator/test_file_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def create_expected_arg(directory: str) -> str:
return fr'^fd=3\(<f>{re.escape(directory)}\/created-by-event-generator\) dirfd=-100\(AT_FDCWD\) name={re.escape(directory)}\/created-by-event-generator flags=20742\(O_TRUNC\|O_CREAT\|O_WRONLY\|O_CLOEXEC\|O_F_CREATED\) mode=0755 dev=.* ino=\d+ $'
return fr'^fd=3\(<f>{re.escape(directory)}\/created-by-event-generator\) dirfd=-100\(AT_FDCWD\) name={re.escape(directory)}\/created-by-event-generator flags=20742\(O_TRUNC\|O_CREAT\|O_WRONLY\|O_CLOEXEC\|O_F_CREATED\) mode=0755 dev=.* ino=\d+$'


def generate_ids(parameters: list) -> list:
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/tests/test_event_generator/test_make_binary_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_make_binary_dirs(sinsp, run_containers: dict):
"thread.tid": SinspField.numeric_field()
},
{
"evt.args": "res=0 dirfd=-100(AT_FDCWD) path=/bin/directory-created-by-event-generator mode=1ED ",
"evt.args": "res=0 dirfd=-100(AT_FDCWD) path=/bin/directory-created-by-event-generator mode=1ED",
"evt.cpu": SinspField.numeric_field(),
"evt.dir": "<",
"evt.num": SinspField.numeric_field(),
Expand All @@ -55,7 +55,7 @@ def test_make_binary_dirs(sinsp, run_containers: dict):
"thread.tid": SinspField.numeric_field()
},
{
"evt.args": "res=-21(EISDIR) dirfd=-100(AT_FDCWD) name=/bin/directory-created-by-event-generator flags=0 ",
"evt.args": "res=-21(EISDIR) dirfd=-100(AT_FDCWD) name=/bin/directory-created-by-event-generator flags=0",
"evt.cpu": SinspField.numeric_field(),
"evt.dir": "<",
"evt.num": SinspField.numeric_field(),
Expand All @@ -75,7 +75,7 @@ def test_make_binary_dirs(sinsp, run_containers: dict):
"thread.tid": SinspField.numeric_field()
},
{
"evt.args": "res=0 dirfd=-100(AT_FDCWD) name=/bin/directory-created-by-event-generator flags=512(AT_REMOVEDIR) ",
"evt.args": "res=0 dirfd=-100(AT_FDCWD) name=/bin/directory-created-by-event-generator flags=512(AT_REMOVEDIR)",
"evt.cpu": SinspField.numeric_field(),
"evt.dir": "<",
"evt.num": SinspField.numeric_field(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_modify_binary_dirs(sinsp, run_containers: dict):
"thread.tid": SinspField.numeric_field()
},
{
"evt.args": "res=0 olddirfd=-100(AT_FDCWD) oldpath=/bin/true newdirfd=-100(AT_FDCWD) newpath=/bin/true.event-generator ",
"evt.args": "res=0 olddirfd=-100(AT_FDCWD) oldpath=/bin/true newdirfd=-100(AT_FDCWD) newpath=/bin/true.event-generator",
"evt.cpu": SinspField.numeric_field(),
"evt.dir": "<",
"evt.num": SinspField.numeric_field(),
Expand All @@ -55,7 +55,7 @@ def test_modify_binary_dirs(sinsp, run_containers: dict):
"thread.tid": SinspField.numeric_field()
},
{
"evt.args": "res=0 olddirfd=-100(AT_FDCWD) oldpath=/bin/true.event-generator newdirfd=-100(AT_FDCWD) newpath=/bin/true ",
"evt.args": "res=0 olddirfd=-100(AT_FDCWD) oldpath=/bin/true.event-generator newdirfd=-100(AT_FDCWD) newpath=/bin/true",
"evt.cpu": SinspField.numeric_field(),
"evt.dir": "<",
"evt.num": SinspField.numeric_field(),
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/test_event_generator/test_network_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_network_activity(sinsp, run_containers: dict):
expected_events = [
{
"container.id": generator_id,
"evt.args": "fd=3(<4>) addr=10.2.3.4:8192 ",
"evt.args": "fd=3(<4>) addr=10.2.3.4:8192",
"evt.category": "net",
"evt.num": SinspField.numeric_field(),
"evt.time": SinspField.numeric_field(),
Expand All @@ -43,7 +43,7 @@ def test_network_activity(sinsp, run_containers: dict):
},
{
"container.id": generator_id,
"evt.args": SinspField.regex_field(fr'^res=0 tuple={ipv4_regex}->10\.2\.3\.4:8192 fd=3\(<4u>{ipv4_regex}->10\.2\.3\.4:8192\) $'),
"evt.args": SinspField.regex_field(fr'^res=0 tuple={ipv4_regex}->10\.2\.3\.4:8192 fd=3\(<4u>{ipv4_regex}->10\.2\.3\.4:8192\)$'),
"evt.category": "net",
"evt.num": SinspField.numeric_field(),
"evt.time": SinspField.numeric_field(),
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/tests/test_event_generator/test_non_sudo_setuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ def test_non_sudo_setuid(sinsp, run_containers):

expected_events = [
{
"evt.args": "uid=2(<NA>) ",
"evt.args": "uid=2(<NA>)",
"evt.dir": ">",
"evt.type": "setuid",
"proc.name": "child",
},
{
"evt.args": "res=0 ",
"evt.args": "res=0",
"evt.dir": "<",
"evt.type": "setuid",
"proc.name": "child",
},
{
"evt.args": "uid=0(<NA>) ",
"evt.args": "uid=0(<NA>)",
"evt.dir": ">",
"evt.type": "setuid",
"proc.name": "child",
},
{
"evt.args": "res=-1(EPERM) ",
"evt.args": "res=-1(EPERM)",
"evt.dir": "<",
"evt.type": "setuid",
"proc.name": "child",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_read_sensitive_file(sinsp, run_containers: dict, expected_process: str)

expected_events = [
{
"evt.args": SinspField.regex_field(r'fd=3\(<f>/etc/shadow\) dirfd=-100\(AT_FDCWD\) name=/etc/shadow flags=4097\(O_RDONLY|O_CLOEXEC\) mode=0 dev=\W+ ino=\d+ '),
"evt.args": SinspField.regex_field(r'fd=3\(<f>/etc/shadow\) dirfd=-100\(AT_FDCWD\) name=/etc/shadow flags=4097\(O_RDONLY|O_CLOEXEC\) mode=0 dev=\W+ ino=\d+'),
"evt.cpu": SinspField.numeric_field(),
"evt.dir": "<",
"evt.num": SinspField.numeric_field(),
Expand Down
18 changes: 9 additions & 9 deletions test/e2e/tests/test_network/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,61 +32,61 @@ def expected_events(origin: dict, destination: dict) -> list:
return [
{
"container.id": origin['id'],
"evt.args": "domain=2(AF_INET) type=1 proto=0 ",
"evt.args": "domain=2(AF_INET) type=1 proto=0",
"evt.category": "net",
"evt.type": "socket",
"fd.name": None,
"proc.cmdline": f"curl --local-port {origin['local_port']} {destination['ip']}",
"proc.exe": "curl",
}, {
"container.id": origin['id'],
"evt.args": "fd=3(<4>) ",
"evt.args": "fd=3(<4>)",
"evt.category": "net",
"evt.type": "socket",
"fd.name": "",
"proc.cmdline": f"curl --local-port {origin['local_port']} {destination['ip']}",
"proc.exe": "curl",
}, {
"container.id": origin['id'],
"evt.args": f"fd=3(<4t>0.0.0.0:{origin['local_port']}) addr={destination['ip']} ",
"evt.args": f"fd=3(<4t>0.0.0.0:{origin['local_port']}) addr={destination['ip']}",
"evt.category": "net",
"evt.type": "connect",
"fd.name": f"0.0.0.0:{origin['local_port']}",
"proc.cmdline": f"curl --local-port {origin['local_port']} {destination['ip']}",
"proc.exe": "curl",
}, {
"container.id": destination['id'],
"evt.args": "flags=0 ",
"evt.args": "flags=0",
"evt.category": "net",
"evt.type": "accept4",
"fd.name": None,
"proc.cmdline": "nginx",
"proc.exe": "nginx: master proces",
}, {
"container.id": destination['id'],
"evt.args": f"fd=3(<4t>{origin['ip']}->{destination['ip']}) tuple={origin['ip']}->{destination['ip']} queuepct=0 queuelen=0 queuemax=511 ",
"evt.args": f"fd=3(<4t>{origin['ip']}->{destination['ip']}) tuple={origin['ip']}->{destination['ip']} queuepct=0 queuelen=0 queuemax=511",
"evt.category": "net",
"evt.type": "accept4",
"fd.name": f"{origin['ip']}->{destination['ip']}",
"proc.cmdline": "nginx",
"proc.exe": "nginx: master proces",
}, {
"evt.args": f"fd=3(<4t>{origin['ip']}->{destination['ip']}) ",
"evt.args": f"fd=3(<4t>{origin['ip']}->{destination['ip']})",
"evt.dir": ">",
"evt.type": "close",
"proc.name": "curl",
}, {
"evt.args": "res=0 ",
"evt.args": "res=0",
"evt.dir": "<",
"evt.type": "close",
"proc.name": "curl",
}, {
"evt.args": f"fd=3(<4t>{origin['ip']}->{destination['ip']}) ",
"evt.args": f"fd=3(<4t>{origin['ip']}->{destination['ip']})",
"evt.dir": ">",
"evt.type": "close",
"proc.name": "nginx",
}, {
"evt.args": "res=0 ",
"evt.args": "res=0",
"evt.dir": "<",
"evt.type": "close",
"proc.name": "nginx",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/test_process/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_exec_in_container(sinsp, run_containers: dict):
expected_events = [
{
'container.id': container_id,
'evt.args': 'filename=/http-echo ',
'evt.args': 'filename=/http-echo',
'evt.category': 'process',
'evt.type': 'execve',
'proc.exe': 'runc',
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ if(WIN32)
elseif(APPLE OR EMSCRIPTEN)
list(REMOVE_ITEM LIBSINSP_UNIT_TESTS_SOURCES
events_net.ut.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parsers/parse_connect.cpp
)
endif()

Expand Down

0 comments on commit 039a5f5

Please sign in to comment.