def _manager_env(self):
        port = 8756
        fs = FileServer(root_path=self.temp_folder, port=port)
        fs.start()
        if os.name == 'nt':
            package_name = 'cloudify-windows-agent.exe'
        else:
            dist = platform.dist()
            package_name = '{0}-{1}-agent.tar.gz'.format(dist[0].lower(),
                                                         dist[2].lower())
        resources_dir = os.path.join(self.temp_folder, 'resources')
        agent_dir = os.path.join(resources_dir, 'packages', 'agents')
        agent_script_dir = os.path.join(resources_dir, 'cloudify_agent')
        os.makedirs(agent_dir)
        os.makedirs(agent_script_dir)
        os.makedirs(os.path.join(self.temp_folder, 'cloudify'))

        agent_path = os.path.join(agent_dir, package_name)
        shutil.copyfile(agent_package.get_package_path(), agent_path)

        new_env = {
            constants.REST_HOST_KEY: 'localhost',
            constants.MANAGER_FILE_SERVER_URL_KEY:
                'http://localhost:{0}'.format(port),
            constants.MANAGER_FILE_SERVER_ROOT_KEY: resources_dir,
            constants.REST_PORT_KEY: str(port),
        }
        with patch.dict(os.environ, new_env):
            try:
                yield
            finally:
                fs.stop()
 def _manager_env(self):
     port = 8756
     fs = FileServer(
         root_path=self.temp_folder, port=port)
     fs.start()
     if os.name == 'nt':
         package_name = 'cloudify-windows-agent.exe'
     else:
         dist = platform.dist()
         package_name = '{0}-{1}-agent.tar.gz'.format(dist[0].lower(),
                                                      dist[2].lower())
     agent_dir = os.path.join(self.temp_folder, 'packages', 'agents')
     os.makedirs(agent_dir)
     agent_path = os.path.join(agent_dir, package_name)
     shutil.copyfile(agent_package.get_package_path(), agent_path)
     resources_dir = os.path.join(self.temp_folder, 'cloudify')
     os.makedirs(resources_dir)
     if os.getenv('AGENT_INSTALL_SCRIPT'):
         install_script_url = os.getenv('AGENT_INSTALL_SCRIPT')
     else:
         install_script_url = _INSTALL_SCRIPT_URL
     urllib.urlretrieve(install_script_url,
                        os.path.join(resources_dir, 'install_agent.py'))
     new_env = {
         constants.MANAGER_IP_KEY: 'localhost',
         constants.MANAGER_FILE_SERVER_URL_KEY:
             'http://localhost:{0}'.format(port)
     }
     with patch.dict(os.environ, new_env):
         try:
             yield
         finally:
             fs.stop()
Пример #3
0
    def setUp(self):
        super(AgentInstallerLocalTest, self).setUp()

        self.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        self.fs = FileServer(root_path=self.resource_base)
        self.fs.start()

        self.addCleanup(self.fs.stop)
        self.addCleanup(shutil.rmtree, self.resource_base)
Пример #4
0
def _make_file_server(tmp_path, agent_ssl_cert, ssl=False):
    base_path = os.path.join(str(tmp_path), 'fileserver')
    if not os.path.exists(base_path):
        os.makedirs(base_path)
    # So that curl -o creates files, make sure we have content
    with open(os.path.join(base_path, 'keep_curl_happy'), 'w') as fh:
        fh.write('')
    return FileServer(agent_ssl_cert, base_path, ssl=ssl)
    def setUp(self):
        super(AgentInstallerLocalTest, self).setUp()
        self.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        self.fs = FileServer(
            root_path=self.resource_base)
        self.fs.start()

        self.addCleanup(self.fs.stop)
        self.addCleanup(shutil.rmtree, self.resource_base)
Пример #6
0
    def setUpClass(cls):
        cls.logger = setup_logger(cls.__name__)
        cls.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        cls.fs = FileServer(
            root_path=cls.resource_base)
        cls.fs.start()

        cls.source_url = get_source_uri()
        cls.requirements_file = get_requirements_uri()
Пример #7
0
    def _manager_env(self):
        port = 8756
        fs = FileServer(root_path=self.temp_folder, port=port)
        fs.start()
        if os.name == 'nt':
            package_name = 'cloudify-windows-agent.exe'
        else:
            dist = platform.dist()
            package_name = '{0}-{1}-agent.tar.gz'.format(
                dist[0].lower(), dist[2].lower())
        resources_dir = os.path.join(self.temp_folder, 'resources')
        agent_dir = os.path.join(resources_dir, 'packages', 'agents')
        agent_script_dir = os.path.join(resources_dir, 'cloudify_agent')
        os.makedirs(agent_dir)
        os.makedirs(agent_script_dir)
        os.makedirs(os.path.join(self.temp_folder, 'cloudify'))

        agent_path = os.path.join(agent_dir, package_name)
        shutil.copyfile(agent_package.get_package_path(), agent_path)

        new_env = {
            constants.REST_HOST_KEY:
            'localhost',
            constants.MANAGER_FILE_SERVER_URL_KEY:
            'http://localhost:{0}'.format(port),
            constants.MANAGER_FILE_SERVER_ROOT_KEY:
            resources_dir,
            constants.REST_PORT_KEY:
            str(port),
        }
        with patch.dict(os.environ, new_env):
            try:
                yield
            finally:
                fs.stop()
Пример #8
0
 def _manager_env(self):
     port = 8756
     fs = FileServer(root_path=self.temp_folder, port=port)
     fs.start()
     if os.name == 'nt':
         package_name = 'cloudify-windows-agent.exe'
     else:
         dist = platform.dist()
         package_name = '{0}-{1}-agent.tar.gz'.format(
             dist[0].lower(), dist[2].lower())
     agent_dir = os.path.join(self.temp_folder, 'packages', 'agents')
     os.makedirs(agent_dir)
     agent_path = os.path.join(agent_dir, package_name)
     shutil.copyfile(agent_package.get_package_path(), agent_path)
     resources_dir = os.path.join(self.temp_folder, 'cloudify')
     os.makedirs(resources_dir)
     if os.getenv('AGENT_INSTALL_SCRIPT'):
         install_script_url = os.getenv('AGENT_INSTALL_SCRIPT')
     else:
         install_script_url = _INSTALL_SCRIPT_URL
     urllib.urlretrieve(install_script_url,
                        os.path.join(resources_dir, 'install_agent.py'))
     new_env = {
         constants.MANAGER_IP_KEY:
         'localhost',
         constants.MANAGER_FILE_SERVER_URL_KEY:
         'http://localhost:{0}'.format(port)
     }
     with patch.dict(os.environ, new_env):
         try:
             yield
         finally:
             fs.stop()
Пример #9
0
class AgentInstallerLocalTest(BaseDaemonLiveTestCase):
    """
    these tests run local workflows in order to invoke the installer
    operations. the remote use case is tested as part of the system tests.
    """
    @classmethod
    def setUpClass(cls):
        cls.logger = setup_logger(cls.__name__)
        cls.source_url = get_source_uri()
        cls.requirements_file = get_requirements_uri()

    def setUp(self):
        super(AgentInstallerLocalTest, self).setUp()

        self.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        self.fs = FileServer(root_path=self.resource_base)
        self.fs.start()

        self.addCleanup(self.fs.stop)
        self.addCleanup(shutil.rmtree, self.resource_base)

    @patch.dict('agent_packager.logger.LOGGER', disable_existing_loggers=False)
    @patch('cloudify.workflows.local._validate_node')
    @only_ci
    def test_local_agent_from_package(self, _):
        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_os('posix')
    @patch('cloudify.workflows.local._validate_node')
    @only_ci
    def test_local_agent_from_package_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes (package)

        Paths longer than 128 bytes break shebangs on linux.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_ci
    @patch('cloudify.workflows.local._validate_node')
    @patch.dict('agent_packager.logger.LOGGER', disable_existing_loggers=False)
    def test_local_agent_from_source(self, _):

        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'ssl_cert_path': self._rest_cert_path
        }

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-source/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_ci
    @patch('cloudify.workflows.local._validate_node')
    @patch.dict('agent_packager.logger.LOGGER', disable_existing_loggers=False)
    def test_3_2_backwards(self, _):

        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'ssl_cert_path': self._rest_cert_path
        }

        blueprint_path = resources.get_resource(
            'blueprints/3_2-agent-from-source/3_2-agent-from-source.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_os('posix')
    @only_ci
    @patch('cloudify.workflows.local._validate_node')
    def test_local_agent_from_source_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes (source)

        This test won't pass on windows because some files within the
        virtualenv exceed 256 bytes, and windows doesn't support paths
        that long.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'ssl_cert_path': self._rest_cert_path
        }

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-source/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
class AgentInstallerLocalTest(BaseDaemonLiveTestCase):

    """
    these tests run local workflows in order to invoke the installer
    operations. the remote use case is tested as part of the system tests.
    """

    @classmethod
    def setUpClass(cls):
        cls.logger = setup_logger(cls.__name__)
        cls.source_url = get_source_uri()
        cls.requirements_file = get_requirements_uri()

    def setUp(self):
        super(AgentInstallerLocalTest, self).setUp()
        self.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        self.fs = FileServer(
            root_path=self.resource_base)
        self.fs.start()

        self.addCleanup(self.fs.stop)
        self.addCleanup(shutil.rmtree, self.resource_base)

    @patch.dict('agent_packager.logger.LOGGER',
                disable_existing_loggers=False)
    @patch('cloudify.workflows.local._validate_node')
    @only_ci
    def test_local_agent_from_package(self, _):
        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_os('posix')
    @patch('cloudify.workflows.local._validate_node')
    @only_ci
    def test_local_agent_from_package_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes

        Paths longer than 128 bytes break shebangs on linux.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_ci
    @patch('cloudify.workflows.local._validate_node')
    @patch.dict('agent_packager.logger.LOGGER',
                disable_existing_loggers=False)
    def test_local_agent_from_source(self, _):

        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue
        }

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-source/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_ci
    @patch('cloudify.workflows.local._validate_node')
    @patch.dict('agent_packager.logger.LOGGER',
                disable_existing_loggers=False)
    def test_3_2_backwards(self, _):

        agent_name = utils.internal.generate_agent_name()
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue
        }

        blueprint_path = resources.get_resource(
            'blueprints/3_2-agent-from-source/3_2-agent-from-source.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)

    @only_os('posix')
    @only_ci
    @patch('cloudify.workflows.local._validate_node')
    def test_local_agent_from_source_long_name(self, _):
        """Agent still works with a filepath longer than 128 bytes

        This test won't pass on windows because some files within the
        virtualenv exceed 256 bytes, and windows doesn't support paths
        that long.
        """
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for i in range(4))
        agent_queue = '{0}-queue'.format(agent_name)

        inputs = {
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue
        }

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-source/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')
        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        self.assert_daemon_alive(name=agent_name)

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(name=agent_name)
Пример #11
0
    def _manager_env(self):
        port = 8756
        fs = FileServer(root_path=self.temp_folder, port=port)
        fs.start()
        self.addCleanup(fs.stop)
        if os.name == 'nt':
            package_name = 'cloudify-windows-agent.exe'
        else:
            dist = platform.dist()
            package_name = '{0}-{1}-agent.tar.gz'.format(
                dist[0].lower(), dist[2].lower())
        resources_dir = os.path.join(self.temp_folder, 'resources')
        agent_dir = os.path.join(resources_dir, 'packages', 'agents')
        agent_script_dir = os.path.join(resources_dir, 'cloudify_agent')
        os.makedirs(agent_dir)
        os.makedirs(agent_script_dir)
        os.makedirs(os.path.join(self.temp_folder, 'cloudify'))

        agent_path = os.path.join(agent_dir, package_name)
        shutil.copyfile(agent_package.get_package_path(), agent_path)
        self.addCleanup(agent_package.cleanup)

        new_env = {
            constants.MANAGER_FILE_SERVER_ROOT_KEY: resources_dir,
            constants.REST_PORT_KEY: str(port),
            constants.MANAGER_NAME: 'cloudify'
        }

        original_create_op_context = operations._get_cloudify_context

        def mock_create_op_context(agent, task_name):
            context = original_create_op_context(agent, task_name)
            context['__cloudify_context']['local'] = True
            return context

        # Need to patch, to avoid broker_ssl_enabled being True
        @contextmanager
        def get_amqp_client(agent):
            yield get_client()

        managers = [
            ManagerItem({
                'networks': {
                    'default': '127.0.0.1'
                },
                'ca_cert_content': agent_ssl_cert.DUMMY_CERT,
                'hostname': 'cloudify'
            })
        ]
        patches = [
            patch.dict(os.environ, new_env),
            patch('cloudify_agent.operations._get_amqp_client',
                  get_amqp_client),
            patch('cloudify.endpoint.LocalEndpoint.get_managers',
                  return_value=managers),
            patch('cloudify_agent.operations._get_cloudify_context',
                  mock_create_op_context),
            get_tenant_mock()
        ]
        for p in patches:
            p.start()
        try:
            yield
        finally:
            for p in patches:
                p.stop()
            fs.stop()
class TestAgentInstallerLocal(BaseDaemonLiveTestCase, unittest.TestCase):

    """
    these tests run local workflows in order to invoke the installer
    operations. the remote use case is tested as part of the system tests.
    """

    @classmethod
    def setUpClass(cls):
        cls.logger = setup_logger(cls.__name__)
        cls.source_url = get_source_uri()
        cls.requirements_file = get_requirements_uri()

    def setUp(self):
        super(TestAgentInstallerLocal, self).setUp()

        self.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        self.fs = FileServer(root_path=self.resource_base)
        self.fs.start()

        self.addCleanup(self.fs.stop)
        self.addCleanup(shutil.rmtree, self.resource_base)

    @only_os('posix')
    @only_ci
    def test_local_agent_from_package_posix(self):
        # Check that agent still works with a filepath longer than 128 bytes
        # (paths longer than 128 bytes break shebangs on linux.)
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for _ in range(4))
        self._test_local_agent_from_package(agent_name)

    @only_os('nt')
    @only_ci
    def test_local_agent_from_package_nt(self):
        agent_name = utils.internal.generate_agent_name()
        self._test_local_agent_from_package(agent_name)

    @patch('cloudify.workflows.local._validate_node')
    @patch('cloudify_agent.installer.operations.delete_agent_rabbitmq_user')
    @patch('cloudify.agent_utils.get_rest_client',
           return_value=MockRestclient())
    def _test_local_agent_from_package(self, agent_name, *_):

        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(agent_queue)
Пример #13
0
class TestAgentInstallerLocal(BaseDaemonLiveTestCase, unittest.TestCase):
    """
    these tests run local workflows in order to invoke the installer
    operations. the remote use case is tested as part of the system tests.
    """
    @classmethod
    def setUpClass(cls):
        cls.logger = setup_logger(cls.__name__)
        cls.source_url = get_source_uri()
        cls.requirements_file = get_requirements_uri()

    def setUp(self):
        super(TestAgentInstallerLocal, self).setUp()

        self.resource_base = tempfile.mkdtemp(
            prefix='file-server-resource-base')
        self.fs = FileServer(root_path=self.resource_base)
        self.fs.start()

        self.addCleanup(self.fs.stop)
        self.addCleanup(shutil.rmtree, self.resource_base)

    @only_os('posix')
    @only_ci
    def test_local_agent_from_package_posix(self):
        # Check that agent still works with a filepath longer than 128 bytes
        # (paths longer than 128 bytes break shebangs on linux.)
        agent_name = 'agent-' + ''.join(uuid.uuid4().hex for _ in range(4))
        self._test_local_agent_from_package(agent_name)

    @only_os('nt')
    @only_ci
    def test_local_agent_from_package_nt(self):
        agent_name = utils.internal.generate_agent_name()
        self._test_local_agent_from_package(agent_name)

    @patch('cloudify.workflows.local._validate_node')
    def _test_local_agent_from_package(self, agent_name, _):

        agent_queue = '{0}-queue'.format(agent_name)

        blueprint_path = resources.get_resource(
            'blueprints/agent-from-package/local-agent-blueprint.yaml')
        self.logger.info('Initiating local env')

        inputs = {
            'resource_base': self.resource_base,
            'source_url': self.source_url,
            'requirements_file': self.requirements_file,
            'name': agent_name,
            'queue': agent_queue,
            'file_server_port': self.fs.port,
            'ssl_cert_path': self._rest_cert_path
        }

        env = local.init_env(name=self._testMethodName,
                             blueprint_path=blueprint_path,
                             inputs=inputs)

        env.execute('install', task_retries=0)
        agent_dict = self.get_agent_dict(env)
        agent_ssl_cert.verify_remote_cert(agent_dict['agent_dir'])

        env.execute('uninstall', task_retries=1)
        self.wait_for_daemon_dead(agent_queue)