-
-
Notifications
You must be signed in to change notification settings - Fork 299
[fix] Use BaseSubnetDivisionRuleType.get_max_subnet order by subnet #728 #729
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,14 @@ jobs: | |||||
| image: redis | ||||||
| ports: | ||||||
| - 6379:6379 | ||||||
| postgres: | ||||||
| image: mdillon/postgis:11-alpine | ||||||
| env: | ||||||
| POSTGRES_PASSWORD: openwisp2 | ||||||
| POSTGRES_USER: openwisp2 | ||||||
| POSTGRES_DB: openwisp2 | ||||||
| ports: | ||||||
| - 5432:5432 | ||||||
|
|
||||||
| strategy: | ||||||
| fail-fast: false | ||||||
|
|
@@ -73,7 +81,9 @@ jobs: | |||||
| ./run-qa-checks | ||||||
| - name: Tests | ||||||
| run: | | ||||||
| coverage run --source=openwisp_controller runtests.py | ||||||
| coverage run runtests.py --parallel | ||||||
| POSTGRESQL=1 coverage run runtests.py --parallel --keepdb | ||||||
| coverage combine | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please try combining these changes with the changes in openwisp/openwisp-users#340 (move flags to rc file and run tests in parallel), in the second call to It should work!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using openwisp-controller/runtests.py Lines 25 to 26 in d25b16c
|
||||||
| # SAMPLE tests | ||||||
| SAMPLE_APP=1 ./runtests.py --keepdb | ||||||
| env: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,39 @@ | ||
| from django.test import TestCase | ||
| from django.db import connection | ||
| from django.test import TestCase, tag | ||
| from openwisp_ipam.tests import CreateModelsMixin as SubnetIpamMixin | ||
| from swapper import load_model | ||
|
|
||
| from ..rule_types.base import BaseSubnetDivisionRuleType | ||
| from ..rule_types.vpn import VpnSubnetDivisionRuleType | ||
|
|
||
| SubnetDivisionRule = load_model('subnet_division', 'SubnetDivisionRule') | ||
|
|
||
| class TestBaseSubnetDivisionRuleType(TestCase): | ||
|
|
||
| class TestBaseSubnetDivisionRuleType(SubnetIpamMixin, TestCase): | ||
| def test_should_create_subnets_ips(self): | ||
| with self.assertRaises(NotImplementedError): | ||
| BaseSubnetDivisionRuleType.should_create_subnets_ips(instance=None) | ||
|
|
||
| def test_provision_for_existing_objects(self): | ||
| with self.assertRaises(NotImplementedError): | ||
| BaseSubnetDivisionRuleType.provision_for_existing_objects(rule_obj=None) | ||
|
|
||
| @tag('db_tests') | ||
| def test_get_max_subnet(self): | ||
| rule = SubnetDivisionRule( | ||
| **{ | ||
| 'label': 'OW', | ||
| 'size': 28, | ||
| 'number_of_ips': 2, | ||
| 'number_of_subnets': 2, | ||
| 'type': VpnSubnetDivisionRuleType, | ||
| } | ||
| ) | ||
| master_subnet = self._create_subnet(subnet='10.0.0.0/16') | ||
| self._create_subnet(subnet='10.0.0.16/28', master_subnet=master_subnet) | ||
| self._create_subnet(subnet='10.0.0.0/28', master_subnet=master_subnet) | ||
| max_subnet = VpnSubnetDivisionRuleType.get_max_subnet(master_subnet, rule) | ||
| if connection.vendor == 'postgresql': | ||
| self.assertEqual(str(max_subnet), '10.0.0.16/28') | ||
| else: | ||
| self.assertEqual(str(max_subnet), '10.0.0.0/28') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ django_redis~=4.12 | |
| mock-ssh-server~=0.9.1 | ||
| responses~=0.12.1 | ||
| selenium~=3.141.0 | ||
| psycopg2-binary~=2.8.0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from .settings import * | ||
|
|
||
| DATABASES = { | ||
| 'default': { | ||
| 'ENGINE': 'django.contrib.gis.db.backends.postgis', | ||
| 'NAME': 'openwisp2', | ||
| 'USER': 'openwisp2', | ||
| 'PASSWORD': 'openwisp2', | ||
| 'HOST': '127.0.0.1', | ||
| 'PORT': '5432', | ||
| }, | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.