예제 #1
0
    def test_can_get_nodes(self):
        adapter = DockerAdapter()
        containers = adapter.find_all_containers('brady/firefox-node:latest')
        if len(containers) == 0:
            print "Not Found"
            return

        print "Total of Firefox Nodes: " + str(len(containers))
예제 #2
0
    def test_can_get_nodes(self):
        adapter = DockerAdapter()
        containers = adapter.find_all_containers("brady/firefox-node:latest")
        if len(containers) == 0:
            print "Not Found"
            return

        print "Total of Firefox Nodes: " + str(len(containers))
예제 #3
0
 def test_can_get_grid_ip(self):
     adapter = DockerAdapter()
     container = adapter.find_container('brady/selenium-grid:latest')
     if not container:
         print "Not Found"
         return
     container_info = adapter.inspect(container['Id'])
     container = dict(container.items() + container_info.items())
     print container['NetworkSettings']['IPAddress']
예제 #4
0
    def test_can_restart_node(self):
        adapter = DockerAdapter()
        containers = adapter.find_all_containers('brady/firefox-node:latest')
        if len(containers) == 0:
            print "Not Found"
            return

        container = containers.pop(0)
        adapter.restart(container)
예제 #5
0
    def test_can_restart_node(self):
        adapter = DockerAdapter()
        containers = adapter.find_all_containers("brady/firefox-node:latest")
        if len(containers) == 0:
            print "Not Found"
            return

        container = containers.pop(0)
        adapter.restart(container)
예제 #6
0
 def test_can_get_grid_ip(self):
     adapter = DockerAdapter()
     container = adapter.find_container("brady/selenium-grid:latest")
     if not container:
         print "Not Found"
         return
     container_info = adapter.inspect(container["Id"])
     container = dict(container.items() + container_info.items())
     print container["NetworkSettings"]["IPAddress"]
예제 #7
0
 def test_can_check_if_grid_running(self):
     adapter = DockerAdapter()
     container = adapter.find_container("brady/selenium-grid:latest")
     if not container:
         print "Not Found"
     print "Found"
     # print container['Status']
     # print container['Ports']
     # print container['Id']
     if "Up" in container["Status"]:
         print "Grid is Running"
     else:
         print "Grid is not Running"
예제 #8
0
 def test_can_check_if_grid_running(self):
     adapter = DockerAdapter()
     container = adapter.find_container('brady/selenium-grid:latest')
     if not container:
         print "Not Found"
     print "Found"
     #print container['Status']
     #print container['Ports']
     #print container['Id']
     if "Up" in container['Status']:
         print "Grid is Running"
     else:
         print "Grid is not Running"
예제 #9
0
파일: build.py 프로젝트: hlobil/dsgrid
class GridBuilder:

    def __init__(self):
        self.adapter = DockerAdapter()

    def is_installed(self):
        container = self.adapter.find_image('dsgrid/selenium-hub')
        return container

    def build(self, container):
        if container == 'phantomjs':
            if not os.path.exists('files/phantomjs'):
                return False
            self.adapter.client.build('files/phantomjs', 'dsgrid/phantomjs-node')
            return True

        if container == 'firefox':
            if not os.path.exists('files/firefox'):
                return False
            self.adapter.client.build('files/firefox', 'dsgrid/firefox-node')
            return True

        if container == 'selenium-hub':
            if not os.path.exists('files/selenium'):
                return False
            self.adapter.client.build('files/selenium', 'dsgrid/selenium-hub')
            return True

        return False
예제 #10
0
파일: build.py 프로젝트: MEDBEDb/dsgrid
class GridBuilder:

    def __init__(self):
        self.adapter = DockerAdapter()

    def is_installed(self):
        container = self.adapter.find_image('dsgrid/selenium-hub')
        return container

    def build(self, container):
        if container == 'phantomjs':
            directory = os.path.join('/usr/local/dsgrid','files','phantomjs')
            if not os.path.exists(directory):
                print "File not found"
 		return False
            self.adapter.client.build(directory, 'dsgrid/phantomjs-node')
            return True

        if container == 'firefox':
            directory = os.path.join('/usr/local/dsgrid','files','firefox')
            if not os.path.exists(directory):
                return False
            self.adapter.client.build(directory, 'dsgrid/firefox-node')
            return True

        if container == 'selenium-hub':
            directory = os.path.join('/usr/local/dsgrid','files','selenium')
            if not os.path.exists(directory):
                return False
            self.adapter.client.build(directory, 'dsgrid/selenium-hub')
            return True

        return False
예제 #11
0
 def test_stop_all_nodes(self):
     adapter = DockerAdapter()
     containers = adapter.client.containers()
     for container in containers:
         if "node" in container['Image']:
             print "Stopping container..."
             adapter.client.stop(container['Id'])
             print "Removing container..."
             adapter.client.remove_container(container['Id'])
예제 #12
0
 def test_start_add_node(self):
     hub = GridHub()
     ip = hub.get_ip()
     print "Grid Hub IP: " + hub.get_ip()
     # sudo docker run -d -e GRID_IP=${GRID_IP} brady/${1}-node
     adapter = DockerAdapter()
     response = adapter.client.create_container('brady/firefox-node', [],
                                                environment={"GRID_IP": ip})
     if response['Id']:
         adapter.client.start(response)
예제 #13
0
class GridBuilder:
    def __init__(self):
        self.adapter = DockerAdapter()

    def is_installed(self):
        container = self.adapter.find_image("dsgrid/selenium-hub")
        return container

    def build(self, container):
        if container == "chrome":
            directory = os.path.join("/usr/local/dsgrid", "files", "chrome")
            if not os.path.exists(directory):
                print "File not found"
                return False
            self.adapter.client.build(directory, "dsgrid/chrome-node")
            return True

        if container == "phantomjs":
            directory = os.path.join("/usr/local/dsgrid", "files", "phantomjs")
            if not os.path.exists(directory):
                print "File not found"
                return False
            self.adapter.client.build(directory, "dsgrid/phantomjs-node")
            return True

        if container == "firefox":
            directory = os.path.join("/usr/local/dsgrid", "files", "firefox")
            if not os.path.exists(directory):
                return False
            self.adapter.client.build(directory, "dsgrid/firefox-node")
            return True

        if container == "selenium-hub":
            directory = os.path.join("/usr/local/dsgrid", "files", "selenium")
            if not os.path.exists(directory):
                return False
            self.adapter.client.build(directory, "dsgrid/selenium-hub")
            return True

        return False
예제 #14
0
class GridBuilder:
    def __init__(self):
        self.adapter = DockerAdapter()

    def is_installed(self):
        container = self.adapter.find_image('dsgrid/selenium-hub')
        return container

    def build(self, container):
        if container == 'chrome':
            directory = os.path.join('/usr/local/dsgrid', 'files', 'chrome')
            if not os.path.exists(directory):
                print "File not found"
                return False
            self.adapter.client.build(directory, 'dsgrid/chrome-node')
            return True

        if container == 'phantomjs':
            directory = os.path.join('/usr/local/dsgrid', 'files', 'phantomjs')
            if not os.path.exists(directory):
                print "File not found"
                return False
            self.adapter.client.build(directory, 'dsgrid/phantomjs-node')
            return True

        if container == 'firefox':
            directory = os.path.join('/usr/local/dsgrid', 'files', 'firefox')
            if not os.path.exists(directory):
                return False
            self.adapter.client.build(directory, 'dsgrid/firefox-node')
            return True

        if container == 'selenium-hub':
            directory = os.path.join('/usr/local/dsgrid', 'files', 'selenium')
            if not os.path.exists(directory):
                return False
            self.adapter.client.build(directory, 'dsgrid/selenium-hub')
            return True

        return False
예제 #15
0
class GridHub:
    VALID_BROWSERS = ('firefox', 'phantomjs', 'chrome')

    def __init__(self):
        self.adapter = DockerAdapter()

    def get_container_info(self):
        container = self.adapter.find_container('dsgrid/selenium-hub:latest')
        if not container:
            # raise exception container not found
            return False
        container_info = self.adapter.inspect(container['Id'])
        container = dict(container.items() + container_info.items())
        return container

    def get_nodes(self):
        nodes = []
        containers = self.adapter.client.containers()

        for container in containers:
            if "node" in container['Image']:
                nodes.append(container)

        return nodes

    def is_running(self):
        container = self.get_container_info()
        if not container:
            # raise exception container not found
            return False
        return "Up" in container['Status']

    def start(self):
        response = self.adapter.client.create_container('dsgrid/selenium-hub',
                                                        ports={"4444/tcp": {}})
        if response['Id']:
            self.adapter.client.start(response, None,
                                      {'4444/tcp': ('', '49044')})

    def get_ip(self):
        container = self.get_container_info()
        return container['NetworkSettings']['IPAddress']

    def add_node(self, browser):
        if not browser in self.VALID_BROWSERS:
            return False
        ip = self.get_ip()
        response = self.adapter.client.create_container(
            'dsgrid/' + browser + '-node', [], environment={"GRID_IP": ip})
        if response['Id']:
            self.adapter.client.start(response)
            return True

    def restart_nodes(self, browser=None):
        containers = self.get_nodes()
        nodes_to_stop = []
        for container in containers:
            if browser is not None and browser not in container['Image']:
                continue
            nodes_to_stop.append(container)

        if len(nodes_to_stop) == 0:
            return False

        for container in nodes_to_stop:
            self.adapter.restart(container)

        return True

    def stop_nodes(self, by_browser=None):
        if by_browser is not None and not by_browser in self.VALID_BROWSERS:
            # raise exception
            return False

        browser = ''
        if by_browser in self.VALID_BROWSERS:
            browser = by_browser + '-'

        containers = self.adapter.client.containers()

        for container in containers:
            if browser + "node" in container['Image']:
                self.adapter.client.stop(container['Id'])
                self.adapter.client.remove_container(container['Id'])

        return True

    def shutdown(self):

        self.stop_nodes()
        container = self.adapter.find_container('dsgrid/selenium-hub:latest')
        if not container:
            # raise exception container not found
            return False
        self.adapter.client.stop(container)
        self.adapter.client.remove_container(container)
예제 #16
0
 def test_can_search_container(self):
     adapter = DockerAdapter()
     image = adapter.find_image("brady/selenium-grid")
     if not image:
         print "Not Found"
     print "Found"
예제 #17
0
 def __init__(self):
     self.adapter = DockerAdapter()
예제 #18
0
파일: hub.py 프로젝트: MEDBEDb/dsgrid
class GridHub:
    VALID_BROWSERS = ('firefox', 'phantomjs')

    def __init__(self):
        self.adapter = DockerAdapter()

    def get_container_info(self):
        container = self.adapter.find_container('dsgrid/selenium-hub:latest')
        if not container:
            # raise exception container not found
            return False
        container_info = self.adapter.inspect(container['Id'])
        container = dict(container.items() + container_info.items())
        return container

    def get_nodes(self):
        nodes = []
        containers = self.adapter.client.containers()

        for container in containers:
            if "node" in container['Image']:
                nodes.append(container)

        return nodes

    def is_running(self):
        container = self.get_container_info()
        if not container:
            # raise exception container not found
            return False
        return "Up" in container['Status']

    def start(self):
        response = self.adapter.client.create_container('dsgrid/selenium-hub', [], ports=["49044:4444"])
        if response['Id']:
            self.adapter.client.start(response)

    def get_ip(self):
        container = self.get_container_info()
        return container['NetworkSettings']['IPAddress']

    def add_node(self, browser):
        if not browser in self.VALID_BROWSERS:
            return False
        ip = self.get_ip()
        response = self.adapter.client.create_container('dsgrid/'+browser+'-node', [], environment={"GRID_IP": ip})
        if response['Id']:
            self.adapter.client.start(response)
            return True

    def restart_nodes(self, browser=None):
        containers = self.get_nodes()
        nodes_to_stop = []
        for container in containers:
            if browser is not None and browser not in container['Image']:
                continue
            nodes_to_stop.append(container)

        if len(nodes_to_stop) == 0:
            return False

        for container in nodes_to_stop:
            self.adapter.restart(container)

        return True

    def stop_nodes(self, by_browser=None):
        if by_browser is not None and not by_browser in self.VALID_BROWSERS:
            # raise exception
            return False

        browser = ''
        if by_browser in self.VALID_BROWSERS:
            browser = by_browser + '-'

        containers = self.adapter.client.containers()

        for container in containers:
            if browser + "node" in container['Image']:
                self.adapter.client.stop(container['Id'])
                self.adapter.client.remove_container(container['Id'])

        return True

    def shutdown(self):

        self.stop_nodes()
        container = self.adapter.find_container('dsgrid/selenium-hub:latest')
        if not container:
            # raise exception container not found
            return False
        self.adapter.client.stop(container)
        self.adapter.client.remove_container(container)
예제 #19
0
 def test_can_search_container(self):
     adapter = DockerAdapter()
     image = adapter.find_image('brady/selenium-grid')
     if not image:
         print "Not Found"
     print "Found"
예제 #20
0
파일: build.py 프로젝트: hlobil/dsgrid
 def __init__(self):
     self.adapter = DockerAdapter()
예제 #21
0
class GridHub:
    VALID_BROWSERS = ("firefox", "phantomjs", "chrome")

    def __init__(self):
        self.adapter = DockerAdapter()

    def get_container_info(self):
        container = self.adapter.find_container("dsgrid/selenium-hub:latest")
        if not container:
            # raise exception container not found
            return False
        container_info = self.adapter.inspect(container["Id"])
        container = dict(container.items() + container_info.items())
        return container

    def get_nodes(self):
        nodes = []
        containers = self.adapter.client.containers()

        for container in containers:
            if "node" in container["Image"]:
                nodes.append(container)

        return nodes

    def is_running(self):
        container = self.get_container_info()
        if not container:
            # raise exception container not found
            return False
        return "Up" in container["Status"]

    def start(self):
        response = self.adapter.client.create_container("dsgrid/selenium-hub", ports={"4444/tcp": {}})
        if response["Id"]:
            self.adapter.client.start(response, None, {"4444/tcp": ("", "49044")})

    def get_ip(self):
        container = self.get_container_info()
        return container["NetworkSettings"]["IPAddress"]

    def add_node(self, browser):
        if not browser in self.VALID_BROWSERS:
            return False
        ip = self.get_ip()
        response = self.adapter.client.create_container("dsgrid/" + browser + "-node", [], environment={"GRID_IP": ip})
        if response["Id"]:
            self.adapter.client.start(response)
            return True

    def restart_nodes(self, browser=None):
        containers = self.get_nodes()
        nodes_to_stop = []
        for container in containers:
            if browser is not None and browser not in container["Image"]:
                continue
            nodes_to_stop.append(container)

        if len(nodes_to_stop) == 0:
            return False

        for container in nodes_to_stop:
            self.adapter.restart(container)

        return True

    def stop_nodes(self, by_browser=None):
        if by_browser is not None and not by_browser in self.VALID_BROWSERS:
            # raise exception
            return False

        browser = ""
        if by_browser in self.VALID_BROWSERS:
            browser = by_browser + "-"

        containers = self.adapter.client.containers()

        for container in containers:
            if browser + "node" in container["Image"]:
                self.adapter.client.stop(container["Id"])
                self.adapter.client.remove_container(container["Id"])

        return True

    def shutdown(self):

        self.stop_nodes()
        container = self.adapter.find_container("dsgrid/selenium-hub:latest")
        if not container:
            # raise exception container not found
            return False
        self.adapter.client.stop(container)
        self.adapter.client.remove_container(container)