def setup_package(): unique_name = 'WorkflowsTests-{0}'.format(id_generator(4)) test_working_dir = os.path.join(TOP_LEVEL_DIR, unique_name) os.makedirs(test_working_dir) testenv.testenv_instance = TestEnvironment(test_working_dir) testenv.testenv_instance.create()
def verify_deployment_environment_creation_complete(deployment_id): # a workaround for waiting for the deployment environment creation to # complete client = create_rest_client() execs = client.executions.list(deployment_id) if not execs or execs[0].status != Execution.TERMINATED or execs[0].workflow_id != "create_deployment_environment": from testenv import TestEnvironment # avoid cyclic import logs = TestEnvironment.read_celery_management_logs() or "" logs = logs[len(logs) - 100000 :] raise RuntimeError( "Expected a single execution for workflow " "'create_deployment_environment' with status 'terminated'; " "Found these executions instead: {0}.\nCelery log:\n{1}".format(json.dumps(execs.items, indent=2), logs) )
def verify_deployment_environment_creation_complete(deployment_id): # a workaround for waiting for the deployment environment creation to # complete client = create_rest_client() execs = client.executions.list(deployment_id) if not execs \ or execs[0].status != Execution.TERMINATED \ or execs[0].workflow_id != 'create_deployment_environment': from testenv import TestEnvironment # avoid cyclic import logs = TestEnvironment.read_celery_management_logs() or '' logs = logs[len(logs) - 100000:] raise RuntimeError( "Expected a single execution for workflow " "'create_deployment_environment' with status 'terminated'; " "Found these executions instead: {0}.\nCelery log:\n{1}".format( json.dumps(execs.items, indent=2), logs))
def test_dsl_with_agent_plugin_and_manager_plugin(self): # start deployment workers deployment_worker = TestEnvironment.create_celery_worker(DEPLOYMENT_ID) self.addCleanup(deployment_worker.close) deployment_worker.start() deployment_workflows_worker = TestEnvironment.create_celery_worker( DEPLOYMENT_WORKFLOWS_QUEUE) self.addCleanup(deployment_workflows_worker.close) deployment_workflows_worker.start() # upload blueprint blueprint_id = self.client.blueprints.upload( resource('dsl/with_plugin.yaml'), BLUEPRINT_ID).id # create deployment self.client.deployments.create(blueprint_id, DEPLOYMENT_ID) # waiting for the deployment environment creation to complete do_retries(verify_deployment_environment_creation_complete, 15, deployment_id=DEPLOYMENT_ID) # test plugin installed in deployment operations worker deployment_plugins = self._get(get_installed_plugins, queue=DEPLOYMENT_ID) self.assertIn('test_management', deployment_plugins) # test plugin installed in deployment workflows worker workflow_plugin = self._get(get_installed_plugins, queue=DEPLOYMENT_WORKFLOWS_QUEUE) self.assertIn('default_workflows', workflow_plugin) # test valid deployment worker installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_ID]) self.assertEquals(state, AFTER_INSTALL_STAGES) # test valid workflows worker installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_WORKFLOWS_QUEUE]) self.assertEquals(state, AFTER_INSTALL_STAGES) # test riemann core started successfully self.assertTrue(self._is_riemann_core_up()) # start agent worker node_id = self._list_nodes()[0].id agent_worker = TestEnvironment.create_celery_worker(node_id) self.addCleanup(agent_worker.close) agent_worker.start() # install self._execute('install') # test plugins installed in agent worker agent_plugins = self._get(get_installed_plugins, queue=node_id) self.assertIn('test', agent_plugins) # test valid agent worker installation order state = self._get(get_worker_state, queue=DEPLOYMENT_ID, args=[node_id]) self.assertEquals(state, AFTER_INSTALL_STAGES) # uninstall self._execute('uninstall') # delete deployment self.client.deployments.delete(DEPLOYMENT_ID) # test valid deployment worker un-installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_ID]) self.assertEquals(state, AFTER_UNINSTALL_STAGES) # test valid workflows worker un-installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_WORKFLOWS_QUEUE]) self.assertEquals(state, AFTER_UNINSTALL_STAGES) # test valid agent worker un-installation order state = self._get(get_worker_state, queue=DEPLOYMENT_ID, args=[node_id]) self.assertEquals(state, AFTER_UNINSTALL_STAGES) # validate riemann core is no longer running self.assertFalse(self._is_riemann_core_up())
def tearDown(): env.destroy()
def setUp(): env.create()
def tearDown(self): super(PoliciesTestsBase, self).tearDown() TestEnvironment.riemann_cleanup()
def tearDown(): TestEnvironment.destroy()
def setUp(): TestEnvironment.create(use_mock_deployment_environment_workflows=False)
def setUp(): TestEnvironment.create(use_mock_workers_installation=False)
def setUpClass(cls): TestEnvironment.create(TestEnvironmentScope.CLASS, False)
def setUp(): TestEnvironment.create()
def test_dsl_with_agent_plugin_and_manager_plugin(self): # start deployment workers deployment_worker = TestEnvironment.create_celery_worker( DEPLOYMENT_ID) self.addCleanup(deployment_worker.close) deployment_worker.start() deployment_workflows_worker = TestEnvironment.create_celery_worker( DEPLOYMENT_WORKFLOWS_QUEUE) self.addCleanup(deployment_workflows_worker.close) deployment_workflows_worker.start() # upload blueprint blueprint_id = self.client.blueprints.upload( resource('dsl/with_plugin.yaml'), BLUEPRINT_ID).id # create deployment self.client.deployments.create(blueprint_id, DEPLOYMENT_ID) # waiting for the deployment workers installation to complete do_retries(verify_workers_installation_complete, 15, deployment_id=DEPLOYMENT_ID) # test plugin installed in deployment operations worker deployment_plugins = self._get(get_installed_plugins, queue=DEPLOYMENT_ID) self.assertIn('test_management_plugin', deployment_plugins) # test plugin installed in deployment workflows worker workflow_plugin = self._get(get_installed_plugins, queue=DEPLOYMENT_WORKFLOWS_QUEUE) self.assertIn('workflows', workflow_plugin) # test valid deployment worker installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_ID]) self.assertEquals(state, AFTER_INSTALL_STAGES) # test valid workflows worker installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_WORKFLOWS_QUEUE]) self.assertEquals(state, AFTER_INSTALL_STAGES) # test riemann core started successfully self.assertTrue(self._is_riemann_core_up()) # start agent worker node_id = self._list_nodes()[0].id agent_worker = TestEnvironment.create_celery_worker(node_id) self.addCleanup(agent_worker.close) agent_worker.start() # install self._execute('install') # test plugins installed in agent worker agent_plugins = self._get(get_installed_plugins, queue=node_id) self.assertIn('test_plugin', agent_plugins) # test valid agent worker installation order state = self._get(get_worker_state, queue=DEPLOYMENT_ID, args=[node_id]) self.assertEquals(state, AFTER_INSTALL_STAGES) # uninstall self._execute('uninstall') # delete deployment self.client.deployments.delete(DEPLOYMENT_ID) # test valid deployment worker un-installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_ID]) self.assertEquals(state, AFTER_UNINSTALL_STAGES) # test valid workflows worker un-installation order state = self._get(get_worker_state, queue=MANAGEMENT, args=[DEPLOYMENT_WORKFLOWS_QUEUE]) self.assertEquals(state, AFTER_UNINSTALL_STAGES) # test valid agent worker un-installation order state = self._get(get_worker_state, queue=DEPLOYMENT_ID, args=[node_id]) self.assertEquals(state, AFTER_UNINSTALL_STAGES) # validate riemann core is no longer running self.assertFalse(self._is_riemann_core_up())