Skip to content

Commit

Permalink
chore(test/libsinsp_e2e,ci): port libsinsp_e2e tests to use python3.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Sep 17, 2024
1 parent 5919fa9 commit 31e5d47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
- name: Install deps
run: |
sudo apt install -y --no-install-recommends clang gcc llvm build-essential cmake python2
sudo apt install -y --no-install-recommends clang gcc llvm build-essential cmake python3 quota
- name: Install kernel headers (actuated)
uses: self-actuated/get-kernel-sources@201eed7d915ac0a6021fb402cde5be7a6b945b59
Expand Down
17 changes: 7 additions & 10 deletions test/libsinsp_e2e/resources/unix_client_server.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#!/usr/bin/python2
#!/usr/bin/python3
# coding: utf-8 -*-
import socket
import os, os.path
import time
import sys

PAYLOAD = "0123456789QWERTYUIOPASDFGHJKLZXCVBNM"
NAME = "/tmp/python_unix_sockets_example"

STARTED = "STARTED"

if sys.argv[1] == 'server':
if os.path.exists(NAME):
os.remove(NAME)

server = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM )
server.bind(NAME)
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

print "STARTED"
print(STARTED)
server.listen(5)

connect, address = server.accept()
Expand All @@ -27,17 +26,15 @@
os.remove(NAME)

else:
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

if os.path.exists(NAME):
client = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM )
client.connect(NAME)

print "STARTED"
print(STARTED)

client.send(PAYLOAD)
client.send(PAYLOAD.encode())
resp = client.recv(1024)
client.close()

else:
print >> sys.stderr, "Couldn't Connect!"
print("Couldn't Connect!", file=sys.stderr)
6 changes: 3 additions & 3 deletions test/libsinsp_e2e/unix_client_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST_F(sys_call_test, unix_client_server) {
event_filter_t filter = [&](sinsp_evt* evt) {
sinsp_threadinfo* ti = evt->get_thread_info(false);
if(ti) {
if(ti->get_comm() == "python2" && ti->m_args.size() >= 1) {
if(ti->get_comm() == "python3" && ti->m_args.size() >= 1) {
return ends_with(ti->m_args[0], "unix_client_server.py") ||
ends_with(ti->m_args[0], "unix_client_server.py");
}
Expand All @@ -103,12 +103,12 @@ TEST_F(sys_call_test, unix_client_server) {
// INITIALIZATION
//
run_callback_t test = [](concurrent_object_handle<sinsp> inspector) {
subprocess server("python2",
subprocess server("python3",
{LIBSINSP_TEST_RESOURCES_PATH "/unix_client_server.py", "server"});

server.wait_for_start();

subprocess client("python2",
subprocess client("python3",
{LIBSINSP_TEST_RESOURCES_PATH "/unix_client_server.py", "client"});
server.wait();
client.wait();
Expand Down

0 comments on commit 31e5d47

Please sign in to comment.