Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL testing is disabled in CI #268

Open
smk4664 opened this issue Sep 4, 2024 · 1 comment
Open

MySQL testing is disabled in CI #268

smk4664 opened this issue Sep 4, 2024 · 1 comment

Comments

@smk4664
Copy link
Contributor

smk4664 commented Sep 4, 2024

Environment

  • Python version: 3.11
  • Nautobot version: 2.3.1
  • nautobot-firewall-models version: 2.1.0

Expected Behavior

Unittests are run in CI and pass.

Observed Behavior

Enabling the MySQL tests will fail in the CI.

Steps to Reproduce

  1. Enable the MySQL tests in the Unittest CI Matrix
  2. Run Unittests.

The tests currently fail the following tests:

WARNINGS:
nautobot_firewall_models.IPRange: (models.W036) MySQL does not support unique constraints with conditions.
	HINT: A constraint won't be created. Silence this warning if you don't care about it.

System check identified 1 issue (0 silenced).
.....................................................................................................................................................................................................................................................................................................ss...........................................................................................................................................................................................s..........F.FFFF........F...F.......................F.F............................................s...s...................................s...s...................................s...s...................................s...s............s.s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s...................................s...s.
======================================================================
FAIL: test_capirca_conversion (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_capirca_conversion)
Verify that generating full config for a polucy is as expected.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 623, in test_capirca_conversion
    self.assertEqual(cap_obj.pol_file, POLICY2)
AssertionError: 'head[26 chars]zone all to-zone all\n}\n\nterm Test {\n  acti[428 chars]n}\n' != 'head[26 chars]zone DMZ to-zone WAN\n}\n\nterm Policy-Rule-1 [428 chars]n}\n'
Diff is 679 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_policy_chd (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_policy_chd)
Test ability to inject custom headers.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 558, in test_policy_chd
    self.assertIn("unique-value", pol[1]["headers"])
AssertionError: 'unique-value' not found in ['srx', 'from-zone', 'DMZ', 'to-zone', 'WAN']

======================================================================
FAIL: test_policy_chd_allow_list (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_policy_chd_allow_list)
Test headers can be allowed and not allowed based on custom field.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 574, in test_policy_chd_allow_list
    self.assertIn("unique-value", pol[1]["headers"])
AssertionError: 'unique-value' not found in ['srx', 'from-zone', 'DMZ', 'to-zone', 'WAN']

======================================================================
FAIL: test_policy_ctd (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_policy_ctd)
Test ability to inject custom terms.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 565, in test_policy_ctd
    self.assertIn("test-custom", pol[1]["terms"])
AssertionError: 'test-custom' not found in {'source-address': ['addr-group1', 'printer'], 'source-port': ['Source-HTTPS'], 'destination-address': ['addr-group3', 'server'], 'destination-port': ['PGSQL', 'svc-group1'], 'protocol': ['tcp'], 'action': 'deny', 'logging': 'true', 'comment': '"req1"'}

======================================================================
FAIL: test_policy_ctd_allow_list (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_policy_ctd_allow_list)
Test terms can be allowed and not allowed based on custom field.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 584, in test_policy_ctd_allow_list
    self.assertIn("test-custom", pol[1]["terms"])
AssertionError: 'test-custom' not found in {'source-address': ['addr-group1', 'printer'], 'source-port': ['Source-HTTPS'], 'destination-address': ['addr-group3', 'server'], 'destination-port': ['PGSQL', 'svc-group1'], 'protocol': ['tcp'], 'action': 'deny', 'logging': 'true', 'comment': '"req1"'}

======================================================================
FAIL: test_svcs_multi_proto_no_port (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_svcs_multi_proto_no_port)
Check that you can mix and match tcp/udp with other protocols, as long as no port.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 511, in test_svcs_multi_proto_no_port
    self.assertEqual(len(pol[1]["terms"]["destination-port"]), 0)
AssertionError: 2 != 0

======================================================================
FAIL: test_validate_policy_data (nautobot_firewall_models.tests.test_capirca.TestPolicyToCapirca.test_validate_policy_data)
Test validate_policy_data produces consistent results.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_capirca.py", line 591, in test_validate_policy_data
    self.assertEqual(cap_obj.policy, POLICY_DATA)
AssertionError: Lists differ: [{'rule-name': 'Test', 'source-address': [], 'source-grou[787 chars] {}}] != [{'rule-name': 'Policy Rule 1', 'source-address': ['print[787 chars] {}}]

First differing element 0:
{'rule-name': 'Test', 'source-address': [], 'source-grou[317 chars]: {}}
{'rule-name': 'Policy Rule 1', 'source-address': ['print[406 chars]: {}}

Diff is 1578 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_policy_to_json (nautobot_firewall_models.tests.test_models.TestNATPolicyModels.test_policy_to_json)
Test method to_json on Policy model.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_models.py", line 330, in test_policy_to_json
    self.assertEqual(json_details["name"], "NAT Policy Rule 1.1")
AssertionError: 'NAT Policy Rule 2.1' != 'NAT Policy Rule 1.1'
- NAT Policy Rule 2.1
?                 ^
+ NAT Policy Rule 1.1
?                 ^


======================================================================
FAIL: test_natpolicyrule_to_json (nautobot_firewall_models.tests.test_models.TestNATPolicyRuleModels.test_natpolicyrule_to_json)
Test method to_json on NATPolicyRule model.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/source/nautobot_firewall_models/tests/test_models.py", line 300, in test_natpolicyrule_to_json
    self.assertEqual(json_details["display"], "NAT Policy Rule 1.1 - req1")
AssertionError: 'NAT Policy Rule 2.1 - req3' != 'NAT Policy Rule 1.1 - req1'
- NAT Policy Rule 2.1 - req3
?                 ^        ^
+ NAT Policy Rule 1.1 - req1
?                 ^        ^


----------------------------------------------------------------------
Ran 1163 tests in 278.619s

FAILED (failures=9, skipped=35)

This could have something to do with MySQL not able to honor the uniqueness constraint.

@jdrew82
Copy link
Contributor

jdrew82 commented Oct 8, 2024

We attempted to fix this at one point here but the IPRange class is what's breaking it. We need to figure out a suitable replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants