Commit 9a5fe3b1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_*: Bootstrap caucase server/connector

  Only launch caucase when needed.  Not all tests need
  caucase, this saves a bit the overhead to run it
parent 3b44783d
......@@ -13,6 +13,7 @@ def convertCategoryList(base, l):
class TestSlapOSBuilderMixin(SlapOSTestCaseMixin):
launch_caucase = 1
def checkSimulationMovement(self, simulation_movement):
self.assertEqual(1.0, simulation_movement.getDeliveryRatio())
......@@ -1798,4 +1799,4 @@ class TestSlapOSAggregatedDeliveryBuilder(SlapOSTestCaseMixin):
self.assertEqual(0.0, built_delivery_line.getPrice())
self.assertEqual(delivery_line_2.getResource(),
built_delivery_line.getResource())
"""
\ No newline at end of file
"""
......@@ -28,6 +28,8 @@ def getSimulationStatePlannedDelivered(self, *args, **kwargs):
return 'planned'
class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
launch_caucase = 1
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -169,6 +171,8 @@ class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
launch_caucase = 1
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -249,6 +253,8 @@ class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
launch_caucase = 1
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -381,6 +387,8 @@ class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
.original_getSimulationState
class TestDefaultPaymentRule(SlapOSTestCaseMixin):
launch_caucase = 1
@withAbort
def test_simulation(self):
SimulationMovement.original_getSimulationState = SimulationMovement\
......@@ -856,6 +864,7 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
.original_getSimulationState
class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
launch_caucase = 1
def test(self):
resource, _, _, _, _, aggregate = self.bootstrapAllocableInstanceTree(is_accountable=True)
......@@ -949,6 +958,8 @@ class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
for q in simulation_movement.contentValues(portal_type='Applied Rule')])
class TestDefaultDeliveryRuleConsumption(SlapOSTestCaseMixin):
launch_caucase = 1
def test(self):
resource, _, _, _, _, aggregate = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = aggregate.getFollowUpValue()
......
......@@ -257,6 +257,8 @@ class TestSlapOSComputerConsumptionTioXMLFile_parseXml(SlapOSTestCaseMixinWithAb
class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
SlapOSTestCaseMixin):
launch_caucase = 1
def createTioXMLFile(self):
document = self.portal.consumption_document_module.newContent(
title=self.generateNewId(),
......
......@@ -30,6 +30,8 @@ from AccessControl.SecurityManagement import getSecurityManager, \
class DefaultScenarioMixin(TestSlapOSSecurityMixin):
launch_caucase = 1
def afterSetUp(self):
TestSlapOSSecurityMixin.afterSetUp(self)
preference = self.portal.portal_preferences.slapos_default_system_preference
......
......@@ -44,6 +44,8 @@ def hashData(data):
class TestSlapOSCloudSlapOSCacheMixin(
SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.pinDateTime(DateTime())
......@@ -375,6 +377,8 @@ class TestSlapOSCloudSlapOSCacheMixin(
class TestSlapOSCloudSoftwareInstance(
SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
......@@ -496,6 +500,7 @@ class TestSlapOSCloudSoftwareInstance(
class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
......@@ -705,4 +710,3 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.assertEqual(fourth_body_fingerprint, hashData(body))
self.assertEqual(0, len(self.portal.portal_activities.getMessageList()))
......@@ -7,6 +7,7 @@ from erp5.component.module.DateUtils import addToDate
class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_assert_instance_tree_successor
#################################################################
......@@ -115,6 +116,7 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(SlapOSTestCaseMixin):
class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_free_compute_partition
#################################################################
......@@ -335,6 +337,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_garbage_collect_destroyed_root_tree
#################################################################
......@@ -448,6 +451,7 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_update_compute_node_capacity_scope
#################################################################
......@@ -624,6 +628,7 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_stop_collect_instance
#################################################################
......@@ -690,6 +695,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_garbage_collect_non_allocated_root_tree
#################################################################
......@@ -904,6 +910,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_cloud_invalidate_destroyed_instance
#################################################################
......@@ -1081,6 +1088,8 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
class TestSlapOSPropagateRemoteNodeInstance(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_cloud_propagate_remote_node_instance
#################################################################
......
......@@ -6,6 +6,8 @@ from unittest import skip
class TestSlapOSAllocation(SlapOSTestCaseMixin):
launch_caucase = 1
def makeAllocableComputeNode(self, project, software_product,
release_variation, type_variation):
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
......
......@@ -22,10 +22,13 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from erp5.component.document.SoftwareInstance import SoftwareInstance, \
DisconnectedSoftwareTree, CyclicSoftwareTree
import transaction
from cryptography import x509
from cryptography.x509.oid import NameOID
class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
"""Tests instance.requestInstance"""
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
......@@ -1050,6 +1053,7 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
"""Tests instance.requestTransfer"""
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
......@@ -1142,7 +1146,6 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
self.software_instance.generateCertificate()
self.assertNotEqual(self.software_instance.getSslKey(), None)
self.assertNotEqual(self.software_instance.getSslCertificate(), None)
self.assertEqual(self.software_instance.getDestinationReference(), None)
certificate_login_list = self.software_instance.objectValues(portal_type="Certificate Login")
self.assertEqual(len(certificate_login_list), 1)
......@@ -1150,11 +1153,11 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
self.assertEqual(certificate_login.getValidationState(), 'validated')
self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertIn(serial, self.software_instance.getSslCertificate())
self.assertIn(certificate_login.getReference(), \
self.software_instance.getSslCertificate().decode('string_escape'))
self.assertNotEqual(certificate_login.getCsrId(), None)
ssl_certificate = x509.load_pem_x509_certificate(self.software_instance.getSslCertificate())
self.assertEqual(len(ssl_certificate.subject), 2)
cn = [i.value for i in ssl_certificate.subject if i.oid == NameOID.COMMON_NAME][0]
self.assertEqual(certificate_login.getReference().decode("UTF-8"), cn)
self.assertRaises(ValueError, self.software_instance.generateCertificate)
def test_revokeCertificate(self):
......@@ -1183,7 +1186,7 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
certificate_login = certificate_login_list[0]
self.assertEqual(certificate_login.getValidationState(), 'validated')
self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None)
self.assertNotEqual(certificate_login.getCsrId(), None)
self.assertNotEqual(self.software_instance.getSslKey(),
ssl_key)
......@@ -1210,12 +1213,11 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
self.assertEqual(another_certificate_login.getValidationState(), 'validated')
self.assertNotEqual(another_certificate_login.getReference(), None)
self.assertNotEqual(another_certificate_login.getDestinationReference(), None)
self.assertNotEqual(another_certificate_login.getCsrId(), None)
self.assertEqual(certificate_login.getValidationState(), 'invalidated')
self.assertNotEqual(certificate_login.getReference(),
another_certificate_login.getReference())
self.assertNotEqual(certificate_login.getDestinationReference(),
another_certificate_login.getDestinationReference())
self.assertNotEqual(certificate_login.getCsrId(),
another_certificate_login.getCsrId())
......@@ -25,6 +25,7 @@ from AccessControl.SecurityManagement import getSecurityManager, \
class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
......
......@@ -1031,6 +1031,7 @@ class TestSlapOSCrmStopInstanceTree(SlapOSTestCaseMixinWithAbort):
class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
launch_caucase = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
......@@ -1252,6 +1253,7 @@ class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort):
launch_caucase = 1
#################################################################
# slapos_crm_check_compute_node_state
......@@ -1528,6 +1530,8 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCaseMixinWithAbort):
launch_caucase = 1
#################################################################
# slapos_crm_check_software_installation_state
#################################################################
......@@ -1770,6 +1774,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
launch_caucase = 1
def _makeInstanceTree(self):
person = self.portal.person_module\
......
......@@ -105,9 +105,12 @@ class TestCRMSkinsMixin(SlapOSTestCaseMixinWithAbort):
return software_installation
class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin):
launch_caucase = 1
def test_SupportRequestModule_getMonitoringUrlList(self):
module = self.portal.support_request_module
# Tic to ensure caucase is indexed
self.tic()
# We assume here that several objects created by others tests don't influentiate
# this test.
self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), [])
......
......@@ -543,6 +543,7 @@ class TestPerson_newLogin(TestSlapOSHalJsonStyleMixin):
self.assertIn(person.getRelativeUrl(), result)
class TestPerson_get_Certificate(TestSlapOSHalJsonStyleMixin):
launch_caucase = 1
def test_Person_getCertificate_unauthorized(self):
person = self._makePerson(user=1)
self.assertEqual(1 , len(person.objectValues(portal_type="ERP5 Login")))
......@@ -562,7 +563,7 @@ class TestPerson_get_Certificate(TestSlapOSHalJsonStyleMixin):
self.assertSameSet(response_dict.keys(), ["common_name", "certificate", "id", "key"])
self.assertEqual(response_dict["id"], login.getDestinationReference())
self.assertEqual(response_dict["id"], login.getCsrId())
self.assertEqual(json.dumps(response_dict["common_name"]), json.dumps(login.getReference()))
self.assertEqual(self.portal.REQUEST.RESPONSE.getStatus(), 200)
......@@ -576,11 +577,11 @@ class TestPerson_get_Certificate(TestSlapOSHalJsonStyleMixin):
self.assertEqual("validated" , login.getValidationState())
self.assertEqual("validated" , new_login.getValidationState())
self.assertNotEqual(login.getReference(), new_login.getReference())
self.assertNotEqual(login.getDestinationReference(), new_login.getDestinationReference())
self.assertNotEqual(login.getCsrId(), new_login.getCsrId())
self.assertSameSet(new_response_dict.keys(), ["common_name", "certificate", "id", "key"])
self.assertEqual(json.dumps(new_response_dict["common_name"]), json.dumps(new_login.getReference()))
self.assertEqual(new_response_dict["id"], new_login.getDestinationReference())
self.assertEqual(new_response_dict["id"], new_login.getCsrId())
self.assertNotEqual(new_response_dict["common_name"], response_dict["common_name"])
self.assertNotEqual(new_response_dict["id"], response_dict["id"])
......@@ -645,6 +646,7 @@ class TestERP5Site_invalidate(TestSlapOSHalJsonStyleMixin):
class TestComputeNode_get_revoke_Certificate(TestSlapOSHalJsonStyleMixin):
launch_caucase = 1
def test_ComputeNode_getCertificate(self):
compute_node = self._makeComputeNode()
self.assertEqual(0, len(compute_node.objectValues(portal_type=["ERP5 Login", "Certificate Login"])))
......@@ -1517,6 +1519,8 @@ return []""")
class TestSoftwareInstance_getAllocationInformation(TestSlapOSHalJsonStyleMixin):
launch_caucase = 1
def test_SoftwareInstance_getAllocationInformation_not_allocated(self):
self._makeTree()
self.changeSkin('RJS')
......
......@@ -32,6 +32,7 @@ from Products.ERP5Type.tests.ERP5TypeFunctionalTestCase import ERP5TypeFunctiona
class TestSlapOSUIHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase):
foreground = 0
run_only = "slaposjs_zuite"
launch_caucase = 1
def afterSetUp(self):
ERP5TypeFunctionalTestCase.afterSetUp(self)
......
......@@ -32,6 +32,7 @@ from Products.ERP5Type.tests.ERP5TypeFunctionalTestCase import ERP5TypeFunctiona
class TestSlapOSUIZHHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase):
foreground = 0
run_only = "slaposjs_zuite"
launch_caucase = 1
def afterSetUp(self):
ERP5TypeFunctionalTestCase.afterSetUp(self)
......
......@@ -32,6 +32,7 @@ from Products.ERP5Type.tests.ERP5TypeFunctionalTestCase import ERP5TypeFunctiona
class TestSlapOSPanelStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase):
foreground = 0
run_only = "slapos_panel_zuite"
launch_caucase = 1
def afterSetUp(self):
ERP5TypeFunctionalTestCase.afterSetUp(self)
......
......@@ -23,6 +23,8 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSPDMCreateUpgradeDecisionSkins(SlapOSTestCaseMixin):
launch_caucase = 1
def test_createUpgradeDecision_destroyed_instance(self):
instance_tree = self.portal.instance_tree_module.newContent(
portal_type="Instance Tree"
......
......@@ -22,6 +22,7 @@
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSDestroySoftwareInstallation(SlapOSTestCaseMixin):
launch_caucase = 1
def bootstrapSoftwareInstallation(self, is_allocated=True, is_supplied=True):
if is_allocated:
......
......@@ -22,6 +22,7 @@
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
launch_caucase = 1
def test_requestUpgrade(self):
software_product, _, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree()
......
......@@ -49,6 +49,7 @@ def canonical_xml(xml):
class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.portal_slap = self.portal.portal_slap
......
......@@ -30,6 +30,7 @@ import random
import transaction
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeCaucaseTestCase import ERP5TypeCaucaseTestCase
from Products.ERP5Type.Utils import convertToUpperCase
import os
import glob
......@@ -40,9 +41,10 @@ from App.config import getConfiguration
config = getConfiguration()
class testSlapOSMixin(ERP5TypeTestCase):
class testSlapOSMixin(ERP5TypeCaucaseTestCase):
abort_transaction = 0
launch_caucase = 0
def clearCache(self):
self.portal.portal_caches.clearAllCache()
......@@ -96,6 +98,8 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.portal.email_from_address = 'romain@nexedi.com'
self.portal.email_to_address = 'romain@nexedi.com'
if not self.isLiveTest() and self.launch_caucase:
self.setUpCaucase()
if getattr(self.portal.portal_caches, 'erp5_site_global_id', None):
# we are not on live test so multiple tests can run in parallel
......@@ -103,8 +107,6 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.portal.portal_caches.erp5_site_global_id = '%s' % random.random()
self.portal.portal_caches._p_changed = 1
if self.isLiveTest():
return
self.commit()
self.portal.portal_caches.updateCache()
......
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