Skip to content

Commit

Permalink
Docker Hardening test - fix flaky test (#33805)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilaner authored Apr 9, 2024
1 parent 1483eea commit eb033dc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Packs/CommonScripts/ReleaseNotes/1_14_29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Scripts

##### DockerHardeningCheck

- Updated the Docker image to: *demisto/python3:3.10.14.91134*.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ args:
defaultValue: cgroup
scripttarget: 0
subtype: python3
dockerimage: demisto/python3:3.10.13.86272
dockerimage: demisto/python3:3.10.14.91134
runas: DBotWeakRole
fromversion: 5.0.0
tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from DockerHardeningCheck import (check_cpus, check_memory, mem_size_to_bytes, check_pids, check_fd_limits,
get_default_gateway, check_network, CLOUD_METADATA_URL)
import pytest
Expand Down Expand Up @@ -26,11 +27,18 @@ def test_fd_limits():
assert check_fd_limits(100, 200)


def test_check_cpus():
if os.getenv("CI"):
pytest.skip("skipping as in CI we run with a single CPU")
return
assert check_cpus(1) # during unit tests we should fail
a = 1


def test_check_cpus(mocker):
import DockerHardeningCheck

def intensive_calc(i):
global a
time.sleep(a * 0.1)
a += 1
mocker.patch.object(DockerHardeningCheck, "intensive_calc", side_effect=intensive_calc)
assert "CPU processing power increased significantly" in check_cpus(1)


def test_get_default_gateway():
Expand Down
2 changes: 1 addition & 1 deletion Packs/CommonScripts/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Common Scripts",
"description": "Frequently used scripts pack.",
"support": "xsoar",
"currentVersion": "1.14.28",
"currentVersion": "1.14.29",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit eb033dc

Please sign in to comment.