Skip to content

Commit

Permalink
db: log warnings to stdout when failed to start redis server
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Aug 31, 2024
1 parent 3c8ac68 commit 502fcef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/CI-production-testing-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ jobs:
run: redis-server --daemonize yes


- name: Test Test
run: python -c 'import os;os.system("ls")'

- name: Test 2
run: python3 slips.py -t -e 1 -f dataset/test7-malicious.pcap -o output/integration_tests/test_configuration_file -c tests/integration_tests/test.yaml -P 6667

Expand Down
13 changes: 8 additions & 5 deletions slips_files/core/database/redis_db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,14 @@ def _start_a_redis_server(cls) -> bool:
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stderr = process.communicate()[1]
stdout, stderr = process.communicate()
stderr = stderr.decode("utf-8")
if stderr:
raise RuntimeError(stderr)
stdout = stdout.decode("utf-8")

if stderr or "warning" in stdout.lower():
raise RuntimeError(
f"database._start_a_redis_server: {stderr}\n" f"{stdout}"
)
return True

@classmethod
Expand All @@ -305,7 +309,6 @@ def connect_to_redis_server(cls) -> Tuple[bool, str]:
Returns a tuple of (bool, error message).
"""
try:

# db 0 changes everytime we run slips
cls.r = cls._connect(cls.redis_port, 0)
# port 6379 db 0 is cache, delete it using -cc flag
Expand All @@ -320,7 +323,7 @@ def connect_to_redis_server(cls) -> Tuple[bool, str]:
cls.r.client_list()
return True, ""
except Exception as e:
return False, str(e)
return False, f"database.connect_to_redis_server: {e}"

@classmethod
def close_redis_server(cls, redis_port):
Expand Down

0 comments on commit 502fcef

Please sign in to comment.