Commit f67aed1c authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Test for proper parameter passing

It has to be ensured, that parameters are correctly passed to the partitions.
parent 8d5910dc
Pipeline #11759 failed with stage
in 0 seconds
......@@ -48,6 +48,7 @@ from slapos.recipe.librecipe import generateHashFromFiles
import xml.etree.ElementTree as ET
import urlparse
import socket
import sqlite3
try:
......@@ -6748,3 +6749,90 @@ class TestSlaveHostHaproxyClash(SlaveHttpFrontendTestCase, TestDataMixin):
)
self.assertEqual(self.certificate_pem, der2pem(result_specific.peercert))
self.assertEqualResultJson(result_specific, 'Path', '/zspecific/test-path')
class TestPassedRequestParameter(HttpFrontendTestCase):
# special SRs to check out
frontend_2_sr = 'special_sr_for_2'
frontend_3_sr = 'special_sr_for_3'
kedifa_sr = 'special_sr_for_kedifa'
@classmethod
def setUpClass(cls):
super(TestPassedRequestParameter, cls).setUpClass()
cls.slap.supply(cls.frontend_2_sr, cls.slap._computer_id)
cls.slap.supply(cls.frontend_3_sr, cls.slap._computer_id)
cls.slap.supply(cls.kedifa_sr, cls.slap._computer_id)
  • @luke Maybe we need to destroy these softwares during tear down. I see in https://nexedijs.erp5.net/#/test_result_module/20201008-8368E590/15 that this is "leaking" to other tests or something.

  • I am on it.

    I expected that eventual leaks would be limited to same test module, can we somehow improve the test system to protect against local issues per module?

  • Thanks !

    That's right, probably we should introduce a tearDownModule that would uninstall all softwares and do nothing in debug mode (when SLAPOS_TEST_DEBUG is set).

  • Anyway pronto 2e6dc54e

Please register or sign in to reply
instance_parameter_dict = {
'port': HTTPS_PORT,
'plain_http_port': HTTP_PORT,
'kedifa_port': KEDIFA_PORT,
'caucase_port': CAUCASE_PORT,
}
@classmethod
def getInstanceParameterDict(cls):
return cls.instance_parameter_dict
def test(self):
self.instance_parameter_dict.update({
'-frontend-quantity': 3,
'-sla-2-computer_guid': self.slap._computer_id,
'-frontend-2-state': 'stopped',
'-frontend-2-software-release-url': self.frontend_2_sr,
'-sla-3-computer_guid': self.slap._computer_id,
'-frontend-3-state': 'stopped',
'-frontend-3-software-release-url': self.frontend_3_sr,
'-kedifa-software-release-url': self.kedifa_sr,
})
# re-request instance with updated parameters
self.requestDefaultInstance()
# run once instance, it's only needed for later checks
try:
self.slap.waitForInstance()
except Exception:
pass
# inspect slapproxy, that the master correctly requested other partitions
sqlitedb_file = os.path.join(
os.path.abspath(
os.path.join(
self.slap.instance_directory, os.pardir
)
), 'var', 'proxy.db'
)
connection = sqlite3.connect(sqlitedb_file)
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
connection.row_factory = dict_factory
cursor = connection.cursor()
cursor.execute(
"select partition_reference, software_release "
"from partition14 where slap_state='busy';")
requested_partition_information = cursor.fetchall()
base_software_url = self.getSoftwareURL()
self.assertEqual(
requested_partition_information,
[
{'software_release': base_software_url,
'partition_reference': 'testing partition 0'},
{'software_release': self.kedifa_sr,
'partition_reference': 'kedifa'},
# that one is base, as expected
{'software_release': base_software_url,
'partition_reference': 'caddy-frontend-1'},
{'software_release': self.frontend_2_sr,
'partition_reference': 'caddy-frontend-2'},
{'software_release': self.frontend_3_sr,
'partition_reference': 'caddy-frontend-3'}]
  • Isn't the order of this select unspecified ? Don't we need to compare sorted lists to be safe ?

Please register or sign in to reply
)
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