Commit 1dcaf841 authored by Xavier Thompson's avatar Xavier Thompson

software/*/test: Blindly replace all _ipv6_address

When IPv6 range is be enabled in testnodes, `_ipv6_address` does not
contain a single IPv6 address shared by all partitions anymore, but
instead the IPv6 range from which each partition will obtain its own
IPv6 address. Instead there is now `computer_partition_ipv6_address`
which contains the IPv6 address of the main partition.

This change blindly replaces all occurences of `_ipv6_address` with
`computer_partition_ipv6_address`, since that will fix most simple
cases. The remaining cases, such as tests with instance trees that
use multiple partitions, can be investigated and fixed individually.
parent 54e5e296
......@@ -45,7 +45,7 @@ class TestBackupServer(InstanceTestCase):
# Check that there is a RSS feed
self.assertTrue('rss' in parameter_dict)
self.assertTrue(parameter_dict['rss'].startswith(
f'https://[{self._ipv6_address}]:9443/'
f'https://[{self.computer_partition_ipv6_address}]:9443/'
))
result = requests.get(
......
......@@ -47,7 +47,7 @@ class TestCaucase(SlapOSInstanceTestCase):
connection_parameter_dict = self.deserializeConnectionParameter()
self.assertEqual(
connection_parameter_dict,
{'url': 'http://[%s]:8009' % (self._ipv6_address,)}
{'url': 'http://[%s]:8009' % (self.computer_partition_ipv6_address,)}
)
result = requests.get(connection_parameter_dict['url'])
......@@ -57,14 +57,14 @@ class TestCaucase(SlapOSInstanceTestCase):
{
'_links': {
'self': {
'href': 'http://[%s]:8009' % (self._ipv6_address,)
'href': 'http://[%s]:8009' % (self.computer_partition_ipv6_address,)
},
'getCAUHAL': {
'href': 'http://[%s]:8009//cau' % (self._ipv6_address,),
'href': 'http://[%s]:8009//cau' % (self.computer_partition_ipv6_address,),
'title': 'cau'
},
'getCASHAL': {
'href': 'http://[%s]:8009//cas' % (self._ipv6_address,),
'href': 'http://[%s]:8009//cas' % (self.computer_partition_ipv6_address,),
'title': 'cas'
}
}
......
......@@ -147,7 +147,7 @@ class TestJupyter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
param_dict = self.getRootPartitionConnectionParameterDict()
self.assertEqual(
'https://[%s]:8888/tree' % self._ipv6_address,
'https://[%s]:8888/tree' % self.computer_partition_ipv6_address,
param_dict['jupyter-url']
)
......
......@@ -138,7 +138,7 @@ class TestJupyter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
param_dict = self.getRootPartitionConnectionParameterDict()
self.assertEqual(
'https://[%s]:8888/tree' % self._ipv6_address,
'https://[%s]:8888/tree' % self.computer_partition_ipv6_address,
param_dict['jupyter-url']
)
......
......@@ -115,7 +115,7 @@ class WendelinTutorialTestCase(FluentdTestCase):
round(random.uniform(-20, 50), 3))]
def serve(self, port, request_handler_class):
server_address = (self._ipv6_address, port)
server_address = (self.computer_partition_ipv6_address, port)
server = OneRequestServer(server_address, request_handler_class)
data = server.get_first_data(FLUSH_INTERVAL)
......@@ -181,7 +181,7 @@ class SensorConfTestCase(WendelinTutorialTestCase):
@type forward
<server>
name myserver1
host {cls._ipv6_address}
host {cls.computer_partition_ipv6_address}
</server>
<buffer>
flush_mode immediate
......@@ -199,7 +199,7 @@ print("{measurement_text}")'''
def test_configuration(self):
self._test_configuration(
fr'adding forwarding server \'myserver1\' host="{self._ipv6_address}" port={FLUENTD_PORT} weight=60'
fr'adding forwarding server \'myserver1\' host="{self.computer_partition_ipv6_address}" port={FLUENTD_PORT} weight=60'
)
def test_send_data(self):
......@@ -232,11 +232,11 @@ class GatewayConfTestCase(WendelinTutorialTestCase):
<source>
@type forward
port {fluentd_port}
bind {cls._ipv6_address}
bind {cls.computer_partition_ipv6_address}
</source>
<match tag.name>
@type wendelin
streamtool_uri http://[{cls._ipv6_address}]:{wendelin_port}/erp5/portal_ingestion_policies/default
streamtool_uri http://[{cls.computer_partition_ipv6_address}]:{wendelin_port}/erp5/portal_ingestion_policies/default
user foo
password bar
<buffer>
......@@ -249,9 +249,9 @@ class GatewayConfTestCase(WendelinTutorialTestCase):
@classmethod
def get_configuration(cls):
fluentd_port = findFreeTCPPort(cls._ipv6_address)
fluentd_port = findFreeTCPPort(cls.computer_partition_ipv6_address)
cls._fluentd_port = fluentd_port
wendelin_port = findFreeTCPPort(cls._ipv6_address)
wendelin_port = findFreeTCPPort(cls.computer_partition_ipv6_address)
cls._wendelin_port = wendelin_port
return cls.gateway_conf(fluentd_port, wendelin_port)
......@@ -260,7 +260,7 @@ class GatewayConfTestCase(WendelinTutorialTestCase):
def test_wendelin_data_forwarding(self):
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.connect((self._ipv6_address, self._fluentd_port))
sock.connect((self.computer_partition_ipv6_address, self._fluentd_port))
data = [
msgpack.ExtType(0, struct.pack('!Q', int(time.time()) << 32)),
......
......@@ -319,7 +319,7 @@ class TestListenInPartition(GrafanaTestCase):
c.laddr for c in self.process_dict['grafana'].connections()
if c.status == 'LISTEN'
],
[(self._ipv6_address, 8180)],
[(self.computer_partition_ipv6_address, 8180)],
)
def test_influxdb_listen(self):
......@@ -330,7 +330,7 @@ class TestListenInPartition(GrafanaTestCase):
]),
[
(self._ipv4_address, 8088),
(self._ipv6_address, 8086),
(self.computer_partition_ipv6_address, 8086),
],
)
......
......@@ -43,7 +43,7 @@ class TestHtmlValidatorServer(InstanceTestCase):
self.assertTrue('vnu-url' in parameter_dict)
self.assertEqual(
'https://[%s]:8899/' % (self._ipv6_address, ),
'https://[%s]:8899/' % (self.computer_partition_ipv6_address, ),
parameter_dict['vnu-url']
)
......
......@@ -52,7 +52,7 @@ class TestJSTestNode(InstanceTestCase):
self.assertEqual(
{
'nginx': 'http://[%s]:9443/' % (self._ipv6_address, )
'nginx': 'http://[%s]:9443/' % (self.computer_partition_ipv6_address, )
},
connection_dict
)
......@@ -83,7 +83,7 @@ class TestJSTestNode(InstanceTestCase):
# Default access
result = requests.get(
'http://[%s]:9443' % (self._ipv6_address, ), allow_redirects=False)
'http://[%s]:9443' % (self.computer_partition_ipv6_address, ), allow_redirects=False)
self.assertEqual(
[requests.codes.forbidden, False],
[result.status_code, result.is_redirect]
......
......@@ -52,10 +52,10 @@ class TestJupyter(InstanceTestCase):
self.assertEqual(
{
'jupyter-classic-url': 'https://[%s]:8888/tree' % (self._ipv6_address, ),
'jupyterlab-url': 'https://[%s]:8888/lab' % (self._ipv6_address, ),
'jupyter-classic-url': 'https://[%s]:8888/tree' % (self.computer_partition_ipv6_address, ),
'jupyterlab-url': 'https://[%s]:8888/lab' % (self.computer_partition_ipv6_address, ),
'password': '%s' % (password, ),
'url': 'https://[%s]:8888/tree' % (self._ipv6_address, )
'url': 'https://[%s]:8888/tree' % (self.computer_partition_ipv6_address, )
},
connection_dict
)
......
......@@ -192,12 +192,12 @@ class TestInstance(InstanceTestCase, KvmMixin):
self.assertEqual(
connection_parameter_dict,
{
'ipv6': self._ipv6_address,
'ipv6': self.computer_partition_ipv6_address,
'maximum-extra-disk-amount': '0',
'monitor-base-url': f'https://[{self._ipv6_address}]:8026',
'nat-rule-port-tcp-22': f'{self._ipv6_address} : 10022',
'nat-rule-port-tcp-443': f'{self._ipv6_address} : 10443',
'nat-rule-port-tcp-80': f'{self._ipv6_address} : 10080',
'monitor-base-url': f'https://[{self.computer_partition_ipv6_address}]:8026',
'nat-rule-port-tcp-22': f'{self.computer_partition_ipv6_address} : 10022',
'nat-rule-port-tcp-443': f'{self.computer_partition_ipv6_address} : 10443',
'nat-rule-port-tcp-80': f'{self.computer_partition_ipv6_address} : 10080',
}
)
self.assertEqual(set(present_key_list), set(assert_key_list))
......@@ -661,19 +661,19 @@ class TestInstanceResilient(InstanceTestCase, KvmMixin):
self.assertRegex(
feed_pull,
'http://\\[{}\\]:[0-9][0-9][0-9][0-9]/get/local-ir0-kvm-1-pull'.format(
self._ipv6_address))
self.computer_partition_ipv6_address))
feed_push = connection_parameter_dict.pop('feed-url-kvm-1-push')
self.assertRegex(
feed_push,
'http://\\[{}\\]:[0-9][0-9][0-9][0-9]/get/local-ir0-kvm-1-push'.format(
self._ipv6_address))
self.computer_partition_ipv6_address))
self.assertEqual(
connection_parameter_dict,
{
'ipv6': self._ipv6_address,
'monitor-base-url': f'https://[{self._ipv6_address}]:8160',
'ipv6': self.computer_partition_ipv6_address,
'monitor-base-url': f'https://[{self.computer_partition_ipv6_address}]:8160',
'monitor-user': 'admin',
'takeover-kvm-1-url': f'http://[{self._ipv6_address}]:9263/',
'takeover-kvm-1-url': f'http://[{self.computer_partition_ipv6_address}]:9263/',
}
)
self.assertEqual(set(present_key_list), set(assert_key_list))
......@@ -1344,11 +1344,11 @@ class TestNatRules(KvmMixin, InstanceTestCase):
self.assertIn('nat-rule-port-tcp-200', connection_parameter_dict)
self.assertEqual(
f'{self._ipv6_address} : 10100',
f'{self.computer_partition_ipv6_address} : 10100',
connection_parameter_dict['nat-rule-port-tcp-100']
)
self.assertEqual(
f'{self._ipv6_address} : 10200',
f'{self.computer_partition_ipv6_address} : 10200',
connection_parameter_dict['nat-rule-port-tcp-200']
)
......@@ -2328,12 +2328,12 @@ vm""",
self.assertEqual(
connection_parameter_dict,
{
'ipv6': self._ipv6_address,
'ipv6': self.computer_partition_ipv6_address,
'maximum-extra-disk-amount': '0',
'monitor-base-url': f'https://[{self._ipv6_address}]:8026',
'nat-rule-port-tcp-22': f'{self._ipv6_address} : 10022',
'nat-rule-port-tcp-443': f'{self._ipv6_address} : 10443',
'nat-rule-port-tcp-80': f'{self._ipv6_address} : 10080',
'monitor-base-url': f'https://[{self.computer_partition_ipv6_address}]:8026',
'nat-rule-port-tcp-22': f'{self.computer_partition_ipv6_address} : 10022',
'nat-rule-port-tcp-443': f'{self.computer_partition_ipv6_address} : 10443',
'nat-rule-port-tcp-80': f'{self.computer_partition_ipv6_address} : 10080',
}
)
self.assertEqual(set(present_key_list), set(assert_key_list))
......
......@@ -86,9 +86,9 @@ class NextCloudTestCase(InstanceTestCase):
mail_smtpport="587",
mail_smtppassword="",
mail_smtpname="",
cli_url="https://[%s]:9988/" % self._ipv6_address,
cli_url="https://[%s]:9988/" % self.computer_partition_ipv6_address,
partition_dir=self.partition_dir,
trusted_domain_list=json.dumps(["[%s]:9988" % self._ipv6_address]),
trusted_domain_list=json.dumps(["[%s]:9988" % self.computer_partition_ipv6_address]),
trusted_proxy_list=[],
)
data_dict.update(config_dict)
......@@ -336,7 +336,7 @@ class TestNextCloudParameters(NextCloudTestCase):
cli_url="nextcloud.example.com",
partition_dir=self.partition_dir,
trusted_domain_list=json.dumps([
"[%s]:9988" % self._ipv6_address,
"[%s]:9988" % self.computer_partition_ipv6_address,
"nextcloud.example.com",
"nextcloud.proxy.com"
]),
......
......@@ -95,7 +95,7 @@ class PowerDNSTestCase(SlapOSInstanceTestCase):
ns_id = 'ns%s' % replicate_nb
ns_record.append(ns_id + '.' + self.default_supported_zone)
expected_dict[ns_id + '-port'] = str(DNS_PORT)
expected_dict[ns_id + '-ipv6'] = self._ipv6_address
expected_dict[ns_id + '-ipv6'] = self.computer_partition_ipv6_address
expected_dict['ns-record'] = ','.join(ns_record)
expected_dict['slave-amount'] = str(slave_amount)
......@@ -203,7 +203,7 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase):
message = dns.message.make_query(domain_name, 'A')
client_subnet_option = dns.edns.ECSOption(subnet)
message.use_edns(options=[client_subnet_option])
answer = dns.query.udp(message, self._ipv6_address, port=DNS_PORT)
answer = dns.query.udp(message, self.computer_partition_ipv6_address, port=DNS_PORT)
return answer.get_rrset(
dns.message.ANSWER,
dns.name.from_text(domain_name),
......
......@@ -444,7 +444,7 @@ class TestDataMixin(object):
# XXX: Dirty decode/encode/decode...?
data_replacement_dict = {
'@@_ipv4_address@@': self._ipv4_address,
'@@_ipv6_address@@': self._ipv6_address,
'@@computer_partition_ipv6_address@@': self.computer_partition_ipv6_address,
'@@_server_http_port@@': str(self._server_http_port),
'@@_server_https_auth_port@@': str(self._server_https_auth_port),
'@@_server_https_port@@': str(self._server_https_port),
......@@ -1063,7 +1063,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
generate_auth_url = parameter_dict.pop('%skey-generate-auth-url' % (
prefix,))
upload_url = parameter_dict.pop('%skey-upload-url' % (prefix,))
kedifa_ipv6_base = 'https://[%s]:%s' % (self._ipv6_address, KEDIFA_PORT)
kedifa_ipv6_base = 'https://[%s]:%s' % (self.computer_partition_ipv6_address, KEDIFA_PORT)
base = '^' + kedifa_ipv6_base.replace(
'[', r'\[').replace(']', r'\]') + '/.{32}'
self.assertRegex(
......@@ -1078,7 +1078,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
kedifa_caucase_url = parameter_dict.pop('kedifa-caucase-url')
self.assertEqual(
kedifa_caucase_url,
'http://[%s]:%s' % (self._ipv6_address, CAUCASE_PORT),
'http://[%s]:%s' % (self.computer_partition_ipv6_address, CAUCASE_PORT),
)
return generate_auth_url, upload_url
......@@ -1380,7 +1380,7 @@ class SlaveHttpFrontendTestCase(HttpFrontendTestCase):
'url': 'http://%s.example.com' % (hostname, ),
'site_url': 'http://%s.example.com' % (hostname, ),
'secure_access': 'https://%s.example.com' % (hostname, ),
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
})
self.assertEqual(
expected_parameter_dict,
......@@ -1429,8 +1429,8 @@ class TestMasterRequestDomain(HttpFrontendTestCase, TestDataMixin):
self.assertEqual(
{
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '0',
'rejected-slave-amount': '0',
......@@ -1461,8 +1461,8 @@ class TestMasterRequest(HttpFrontendTestCase, TestDataMixin):
self.assertNodeInformationWithPop(parameter_dict)
self.assertEqual(
{
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'None',
'accepted-slave-amount': '0',
'rejected-slave-amount': '0',
......@@ -1577,8 +1577,8 @@ class TestMasterAIKCDisabledAIBCCDisabledRequest(
self.assertNodeInformationWithPop(parameter_dict)
self.assertEqual(
{
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'None',
'accepted-slave-amount': '0',
'rejected-slave-amount': '0',
......@@ -1937,7 +1937,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
monitor_setup_url_key = 'monitor-setup-url'
def test_monitor_setup(self):
IP = self._ipv6_address
IP = self.computer_partition_ipv6_address
self.monitor_configuration_list = [
{
'htmlUrl': 'https://[%s]:8401/public/feed' % (IP,),
......@@ -2098,8 +2098,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
self.assertNodeInformationWithPop(parameter_dict)
expected_parameter_dict = {
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '62',
'rejected-slave-amount': '0',
......@@ -2429,14 +2429,14 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
# check out access via IPv6
out_ipv6, err_ipv6 = self._curl(
parameter_dict['domain'], self._ipv6_address, HTTPS_PORT)
parameter_dict['domain'], self.computer_partition_ipv6_address, HTTPS_PORT)
try:
j = json.loads(out_ipv6.decode())
except Exception:
raise ValueError('JSON decode problem in:\n%s' % (out_ipv6.decode(),))
self.assertEqual(
self._ipv6_address,
self.computer_partition_ipv6_address,
j['Incoming Headers']['x-forwarded-for']
)
......@@ -4871,7 +4871,7 @@ class TestReplicateSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
'url': 'http://replicate.example.com',
'site_url': 'http://replicate.example.com',
'secure_access': 'https://replicate.example.com',
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
},
parameter_dict
)
......@@ -5331,8 +5331,8 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
self.assertRejectedSlavePromiseEmptyWithPop(parameter_dict)
expected_parameter_dict = {
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '12',
'rejected-slave-amount': '0',
......@@ -5838,8 +5838,8 @@ class TestSlaveSlapOSMasterCertificateCompatibilityUpdate(
self.assertRejectedSlavePromiseEmptyWithPop(parameter_dict)
expected_parameter_dict = {
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '1',
'rejected-slave-amount': '0',
......@@ -5930,8 +5930,8 @@ class TestSlaveCiphers(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertRejectedSlavePromiseEmptyWithPop(parameter_dict)
expected_parameter_dict = {
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '2',
'rejected-slave-amount': '0',
......@@ -6192,8 +6192,8 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
self.assertRejectedSlavePromiseWithPop(parameter_dict)
expected_parameter_dict = {
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'monitor-base-url': 'https://[%s]:8401' % self.computer_partition_ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '3',
'rejected-slave-amount': '28',
......@@ -6428,7 +6428,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
'url': 'http://defaultpathunsafe.example.com',
'site_url': 'http://defaultpathunsafe.example.com',
'secure_access': 'https://defaultpathunsafe.example.com',
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self.computer_partition_ipv6_address,
},
parameter_dict
)
......@@ -6722,8 +6722,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase):
'kedifa'].pop('monitor-password')
)
backend_client_caucase_url = 'http://[%s]:8990' % (self._ipv6_address,)
kedifa_caucase_url = 'http://[%s]:15090' % (self._ipv6_address,)
backend_client_caucase_url = 'http://[%s]:8990' % (self.computer_partition_ipv6_address,)
kedifa_caucase_url = 'http://[%s]:15090' % (self.computer_partition_ipv6_address,)
expected_partition_parameter_dict_dict = {
'caddy-frontend-1': {
'X-software_release_url': base_software_url,
......
......@@ -125,7 +125,7 @@ class TestJupyter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
param_dict = self.getRootPartitionConnectionParameterDict()
self.assertEqual(
f'https://[{self._ipv6_address}]:8888/tree',
f'https://[{self.computer_partition_ipv6_address}]:8888/tree',
param_dict['jupyter-url']
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment