Пример #1
0
    def setUp(self) -> None:
        TempDirFixture.setUp(self)
        DockerTestCase.setUp(self)

        self.dirs_to_remove: List[PathOrStr] = []
        self.files_to_remove: List[PathOrStr] = []
        self.node: Optional[Node] = None
Пример #2
0
 def setUp(self):
     TempDirFixture.setUp(self)
     DockerTestCase.setUp(self)
     self.error_msg = None
     self.dirs_to_remove = []
     self.files_to_remove = []
     self.node = None
     self._send_task_failed = TaskServer.send_task_failed
Пример #3
0
    def tearDown(self):
        if self.node and self.node.client:
            self.node.client.quit()
        for dir in self.dirs_to_remove:
            shutil.rmtree(dir)

        TaskServer.send_task_failed = self._send_task_failed

        DockerTestCase.tearDown(self)
        TempDirFixture.tearDown(self)
    def setUp(self):
        TempDirFixture.setUp(self)

        self.src_file = os.path.join(self.tempdir, 'src_file')
        self.dst_file_name = 'dst_file'
        self.dst_file_path = self.tempdir

        with open(self.src_file, 'w') as f:
            for _ in xrange(100):
                f.write(str(uuid.uuid4()))
Пример #5
0
    def setUp(self):
        TempDirFixture.setUp(self)
        LogTestCase.setUp(self)

        self.docker_manager = mock.Mock()
        self.virtualbox = mock.Mock()
        self.ISession = mock.Mock()
        self.LockType = mock.Mock()

        self.hypervisor = XhyveHypervisor(self.docker_manager)
        self.hypervisor.command_calls = []
        self.hypervisor.command = types.MethodType(command, self.hypervisor)
Пример #6
0
    def tearDown(self):
        if self.node and self.node.client:
            self.node.client.quit()
        for f in self.files_to_remove:
            if path.isfile(f):
                remove(f)
        for dir_ in self.dirs_to_remove:
            if path.isdir(dir_):
                shutil.rmtree(dir_)
        TaskServer.send_task_failed = self._send_task_failed

        DockerTestCase.tearDown(self)
        TempDirFixture.tearDown(self)
Пример #7
0
    def tearDown(self) -> None:
        if self.node and self.node.client:
            self.node.client.quit()

        for f in self.files_to_remove:
            if os.path.isfile(f):
                os.remove(f)

        for d in self.dirs_to_remove:
            if os.path.isdir(d):
                shutil.rmtree(d)

        DockerTestCase.tearDown(self)
        TempDirFixture.tearDown(self)
Пример #8
0
    def setUp(self):
        TempDirFixture.setUp(self)

        self.dir_manager = DirManager(self.path)
        res_path = self.dir_manager.get_task_resource_dir('task2')

        file1 = os.path.join(res_path, 'file1')
        file2 = os.path.join(res_path, 'file2')
        dir1 = os.path.join(res_path, 'dir1')
        file3 = os.path.join(dir1, 'file3')
        open(file1, 'w').close()
        open(file2, 'w').close()
        if not os.path.isdir(dir1):
            os.mkdir(dir1)
        open(file3, 'w').close()
Пример #9
0
    def setUp(self):
        TempDirFixture.setUp(self)
        LogTestCase.setUp(self)

        self.task_id = str(uuid.uuid4())

        client_1, dir_1, session_1 = self._create_client(self.task_id, '_1')
        client_2, dir_2, session_2 = self._create_client(self.task_id, '_2')

        self.client_1 = client_1
        self.client_2 = client_2
        self.resource_dir_1 = dir_1
        self.resource_dir_2 = dir_2
        self.task_session_1 = session_1
        self.task_session_2 = session_2

        self.resources_relative, resources = self._create_resources(
            self.resource_dir_1)
        client_1.resource_server.resource_manager.add_task(
            resources, self.task_id, async_=False)
Пример #10
0
 def tearDownClass(cls):
     TestWithReactor.tearDownClass()
     TestDirFixture.tearDownClass()
Пример #11
0
 def setUpClass(cls):
     TestDirFixture.setUpClass()
     TestWithReactor.setUpClass()
Пример #12
0
    def setUp(self):
        TempDirFixture.setUp(self)

        self.task_id = str(uuid.uuid4())

        self.datadir_1 = os.path.join(self.path, 'node_1')
        self.datadir_2 = os.path.join(self.path, 'node_2')

        self.dir_manager_1 = DirManager(self.datadir_1)
        self.dir_manager_2 = DirManager(self.datadir_2)

        self.resource_manager_1 = self._resource_manager_class(
            self.dir_manager_1)
        self.resource_manager_2 = self._resource_manager_class(
            self.dir_manager_2)

        self.client_1 = Client(datadir=self.datadir_1,
                               connect_to_known_hosts=False,
                               use_docker_machine_manager=False,
                               use_monitor=False)
        self.client_2 = Client(datadir=self.datadir_2,
                               connect_to_known_hosts=False,
                               use_docker_machine_manager=False,
                               use_monitor=False)
        self.client_1.start = self.client_2.start = Mock()

        self.resource_server_1 = BaseResourceServer(self.resource_manager_1,
                                                    self.dir_manager_1, Mock(),
                                                    self.client_1)
        self.resource_server_2 = BaseResourceServer(self.resource_manager_2,
                                                    self.dir_manager_2, Mock(),
                                                    self.client_2)
        self.resource_server_1.client.resource_server = self.resource_server_1
        self.resource_server_2.client.resource_server = self.resource_server_2

        task_server_1 = TaskServer.__new__(TaskServer, Mock(), Mock(), Mock(),
                                           self.client_1)
        task_server_2 = TaskServer.__new__(TaskServer, Mock(), Mock(), Mock(),
                                           self.client_2)
        task_server_1.client = self.client_1
        task_server_2.client = self.client_2
        task_server_1.keys_auth = self.client_1.keys_auth
        task_server_2.keys_auth = self.client_2.keys_auth
        task_server_1.sync_network = task_server_2.sync_network = Mock()
        task_server_1.start_accepting = task_server_2.start_accepting = Mock()
        task_server_1.task_computer = task_server_2.task_computer = Mock()

        self.client_1.task_server = task_server_1
        self.client_2.task_server = task_server_2

        self.task_session_1 = TaskSession(Mock())
        self.task_session_2 = TaskSession(Mock())
        self.task_session_1.task_server = task_server_1
        self.task_session_2.task_server = task_server_2
        self.task_session_1.task_id = self.task_session_2.task_id = self.task_id

        self.resource_dir_1 = self.resource_manager_1.storage.get_dir(
            self.task_id)
        self.resource_dir_2 = self.resource_manager_2.storage.get_dir(
            self.task_id)

        client_options = self.resource_manager_1.build_client_options(
            task_server_1.get_key_id())

        self.resources_relative, self.resources = self._create_resources(
            self.resource_dir_1)
        self.resource_manager_1._add_task(self.resources,
                                          self.task_id,
                                          client_options=client_options)
Пример #13
0
 def tearDown(self):
     self.client_1.quit()
     self.client_2.quit()
     TempDirFixture.tearDown(self)
Пример #14
0
    def tearDown(self):
        self.client_1.quit()
        self.client_2.quit()

        LogTestCase.tearDown(self)
        TempDirFixture.tearDown(self)