Skip to content

Commit

Permalink
tests: improve coverage with ignore_errors
Browse files Browse the repository at this point in the history
config_fuzzer: run generate against the whole dataset generated by the
config fuzzer and ignore all the errors.

integration/run.py: run integration tests a second time with
ignore_errors set via the NETPLAN_PARSER_IGNORE_ERRORS environment
variable.

integration/dbus.py: call apply after set. Without that, the netplan
state will be considered dirty and the dbus tests will fail when called
a second time.
  • Loading branch information
daniloegea committed Apr 29, 2024
1 parent 081aa09 commit 37de4f2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/config_fuzzer/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,31 @@ done

echo "$(date) - Done"

echo "$(date) - Running netplan generate -i"

# Run netplan generate against all the YAMLs at once ignoring errors
# We generate a new and smaller batch for this test due to an annoying memory
# leak that seems to happen in glib when lots of entries are added to a datalist.
mkdir -p fakeroot3/etc
node index.js 100
mv fakedata fakeroot3/etc/netplan

${NETPLAN_GENERATE_PATH} --root-dir fakeroot3 -i > "${RESULTS_DIR}"/generate_i.log 2>&1
code=$?
if [ $code -eq 139 ] || [ $code -eq 245 ] || [ $code -eq 133 ]
then
echo "GENERATE -i CRASHED"
error=1
fi

if grep 'detected memory leaks' "${RESULTS_DIR}/generate_i.log" > /dev/null
then
echo "GENERATE -i MEMORY LEAK DETECTED"
# Try to get a clue of what happen by looking at the neighborhood of the detected memory leaks text
grep -A30 -B30 'detected memory leaks' "${RESULTS_DIR}/generate_i.log"
error=1
fi

echo "$(date) - Done"

exit ${error}
5 changes: 5 additions & 0 deletions tests/integration/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def test_dbus_config_set(self):
# The path has the following format: /io/netplan/Netplan/config/WM6X01
BUSCTL_CONFIG_GET[5] = config_path
BUSCTL_CONFIG_SET[5] = config_path
BUSCTL_CONFIG_APPLY[5] = config_path

# Changing the configuration
out = subprocess.run(BUSCTL_CONFIG_SET, capture_output=True, text=True)
Expand All @@ -173,6 +174,10 @@ def test_dbus_config_set(self):
self.assertEqual(NETPLAN_YAML_AFTER % {'nic': self.dev_e_client},
netplan_data, msg="The final YAML is different than expected")

# Applying the configuration
out = subprocess.run(BUSCTL_CONFIG_APPLY, capture_output=True, text=True)
self.assertEqual(out.returncode, 0, msg=f"Busctl Apply() failed with error: {out.stderr}")

def test_dbus_config_apply(self):
NETPLAN_YAML = '''network:
version: 2
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,11 @@ def dedupe(duped_list):
if returncode == 0 and ret != 0:
returncode = ret

# Running tests again with NETPLAN_PARSER_IGNORE_ERRORS
os.environ["NETPLAN_PARSER_IGNORE_ERRORS"] = "1"
ret = subprocess.call(['python3', os.path.join(tests_dir, "{}.py".format(test))])
if returncode == 0 and ret != 0:
returncode = ret
os.environ.pop("NETPLAN_PARSER_IGNORE_ERRORS")

sys.exit(returncode)

0 comments on commit 37de4f2

Please sign in to comment.