Esempio n. 1
0
 def start_manager(self):
     if TEST_DOCKER_JOB_MANAGER == "boot2docker":
         self.job_manager = RemoteDockerJobManager([{
             "remote_host": "192.168.59.103",
             "remote_docker_port": 2375,
             "remote_agent_port": 63456
         }], {"default": "ingi/inginious-c-default"}, is_testing=True)
     elif TEST_DOCKER_JOB_MANAGER == "travis":
         self.job_manager = RemoteDockerJobManager([{
             "remote_host": "localhost",
             "remote_docker_port": 2375,
             "remote_agent_port": 63456
         }], {"default": "ingi/inginious-c-default"}, is_testing=True)
     self.job_manager.start()
Esempio n. 2
0
 def test_invalid_agent_already_started(self):
     assert RemoteDockerJobManager.is_agent_valid_and_started(self.docker_connection) is False
Esempio n. 3
0
class TestDockerJobManager(object):
    def setUp(self):

        if TEST_DOCKER_JOB_MANAGER is None:
            raise SkipTest("Testing the Docker Job Manager is disabled.")
        elif TEST_DOCKER_JOB_MANAGER == "boot2docker":
            self.docker_connection = docker.Client(base_url="tcp://192.168.59.103:2375")
        elif TEST_DOCKER_JOB_MANAGER == "travis":
            self.docker_connection = docker.Client(base_url="tcp://localhost:2375")
        else:
            raise Exception("Unknown method for testing the Docker Job Manager!")

        # Force the removal of all containers/images linked to this test
        try:
            self.docker_connection.remove_container("inginious-agent", force=True)
        except:
            pass

        try:
            self.docker_connection.remove_image("ingi/inginious-agent", force=True)
        except:
            pass

        self.setUpDocker()
        self.job_manager = None
        self.setUpJobManager()

    def setUpDocker(self):
        pass

    def setUpJobManager(self):
        pass

    def start_manager(self):
        if TEST_DOCKER_JOB_MANAGER == "boot2docker":
            self.job_manager = RemoteDockerJobManager([{
                "remote_host": "192.168.59.103",
                "remote_docker_port": 2375,
                "remote_agent_port": 63456
            }], {"default": "ingi/inginious-c-default"}, is_testing=True)
        elif TEST_DOCKER_JOB_MANAGER == "travis":
            self.job_manager = RemoteDockerJobManager([{
                "remote_host": "localhost",
                "remote_docker_port": 2375,
                "remote_agent_port": 63456
            }], {"default": "ingi/inginious-c-default"}, is_testing=True)
        self.job_manager.start()

    def build_fake_agent(self, dockerfile="FakeAgentDockerfile"):
        dockerfile_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "utils/"))
        print [line for line in self.docker_connection.build(dockerfile_dir, dockerfile=dockerfile, rm=True, tag="ingi/inginious-agent")]

    def start_fake_agent(self):
        response = self.docker_connection.create_container(
            "ingi/inginious-agent",
            detach=True,
            name="inginious-agent"
        )
        container_id = response["Id"]

        # Start the container
        self.docker_connection.start(container_id)

    def tearDown(self):
        # sanitize a bit Docker...
        if self.job_manager is not None:
            self.job_manager.close()

        try:
            self.docker_connection.remove_container("inginious-agent", force=True)
        except:
            pass

        try:
            self.docker_connection.remove_image("ingi/inginious-agent", force=True)
        except:
            pass
Esempio n. 4
0
 def test_agent_no_image(self):
     assert RemoteDockerJobManager.is_agent_image_update_needed(self.docker_connection) is True