Commit f46d4ab0 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 8497c26d
......@@ -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())
......
......@@ -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\
......@@ -857,6 +865,7 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
.original_getSimulationState
class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
launch_caucase = 1
def test(self):
resource, _, _, _, _, aggregate = self.bootstrapAllocableInstanceTree(is_accountable=True)
......@@ -950,6 +959,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
......
......@@ -52,6 +52,8 @@ def _decode_with_json(value):
class TestSlapOSCloudSlapOSCacheMixin(
SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.pinDateTime(DateTime())
......@@ -430,6 +432,8 @@ class TestBase_isValidXml(SlapOSTestCaseMixinWithAbort):
class TestSlapOSCloudSoftwareInstance(
SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
......@@ -659,6 +663,8 @@ class TestSlapOSCloudSoftwareInstance(
class TestSlapOSCloudSlaveInstance(
TestSlapOSCloudSoftwareInstance):
launch_caucase = 1
def _skipTest(self):
pass
......@@ -677,6 +683,7 @@ class TestSlapOSCloudSlaveInstance(
class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
......@@ -890,6 +897,7 @@ class TestSlapOSCloudSlapOSComputeNodeMixin_getCacheComputeNodeInformation(
self.assertEqual(0, len(self.portal.portal_activities.getMessageList()))
class TestSlapOSCloudInstanceInvalidRequest(SlapOSTestCaseMixin):
launch_caucase = 1
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
......
......@@ -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
#################################################################
......@@ -353,6 +355,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_garbage_collect_destroyed_root_tree
#################################################################
......@@ -470,6 +473,7 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_update_compute_node_capacity_scope
#################################################################
......@@ -700,6 +704,7 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_stop_collect_instance
#################################################################
......@@ -766,6 +771,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_garbage_collect_non_allocated_root_tree
#################################################################
......@@ -980,6 +986,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
launch_caucase = 1
#################################################################
# slapos_cloud_invalidate_destroyed_instance
#################################################################
......@@ -1157,6 +1164,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,11 +22,14 @@ 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)
portal = self.getPortalObject()
......@@ -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)
......
......@@ -1032,6 +1032,7 @@ class TestSlapOSCrmStopInstanceTree(SlapOSTestCaseMixinWithAbort):
class TestSlapOSCrmDeleteInstanceTree(SlapOSTestCaseMixinWithAbort):
launch_caucase = 1
def createRegularisationRequest(self):
new_id = self.generateNewId()
......
......@@ -123,6 +123,7 @@ class TestSlapOSCrmMonitoringCheckComputeNodeProjectState(TestSlapOSCrmMonitorin
class TestSlapOSCrmMonitoringCheckComputeNodeState(TestSlapOSCrmMonitoringMixin):
launch_caucase = 1
##########################################################################
# ComputeNode_checkProjectMontoringState > ComputeNode_checkMonitoringState
##########################################################################
......
......@@ -229,6 +229,8 @@ class TestCRMPropertySheetConstraint(SlapOSTestCaseMixin):
class TestProject_createTicketWithCausality(TestCRMSkinsMixin):
launch_caucase = 1
def testProject_createTicketWithCausality(self):
self._makeComputeNode(self.project)
self._makeComplexComputeNode(self.project)
......
......@@ -541,7 +541,7 @@ class TestPerson_newLogin(TestSlapOSHalJsonStyleMixin):
self.assertEqual(self.portal.REQUEST.RESPONSE.getStatus(), 200)
self.assertIn(person.getRelativeUrl(), result)
class TestPerson_testLoginExistence(TestSlapOSHalJsonStyleMixin):
def test_Person_testLoginExistence(self, portal_type="ERP5 Login"):
......@@ -599,6 +599,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"])))
......@@ -1444,6 +1445,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