Пример #1
0
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()
Пример #2
0
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)
        )
Пример #3
0
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())
Пример #5
0
def tearDown():
    env.destroy()
Пример #6
0
def setUp():
    env.create()
 def tearDown(self):
     super(PoliciesTestsBase, self).tearDown()
     TestEnvironment.riemann_cleanup()
Пример #8
0
def tearDown():
    TestEnvironment.destroy()
Пример #9
0
def tearDown():
    env.destroy()
Пример #10
0
 def tearDown(self):
     super(PoliciesTestsBase, self).tearDown()
     TestEnvironment.riemann_cleanup()
Пример #11
0
def setUp():
    TestEnvironment.create(use_mock_deployment_environment_workflows=False)
Пример #12
0
def setUp():
    TestEnvironment.create(use_mock_workers_installation=False)
Пример #13
0
 def setUpClass(cls):
     TestEnvironment.create(TestEnvironmentScope.CLASS, False)
Пример #14
0
def tearDown():
    TestEnvironment.destroy()
Пример #15
0
def setUp():
    TestEnvironment.create(use_mock_deployment_environment_workflows=False)
Пример #16
0
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())
Пример #18
0
 def setUpClass(cls):
     TestEnvironment.create(TestEnvironmentScope.CLASS, False)
Пример #19
0
def setUp():
    TestEnvironment.create()
Пример #20
0
def setUp():
    env.create()