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))
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))
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']
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)
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)
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"]
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"
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"
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
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
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'])
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)
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
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
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)
def test_can_search_container(self): adapter = DockerAdapter() image = adapter.find_image("brady/selenium-grid") if not image: print "Not Found" print "Found"
def __init__(self): self.adapter = DockerAdapter()
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)
def test_can_search_container(self): adapter = DockerAdapter() image = adapter.find_image('brady/selenium-grid') if not image: print "Not Found" print "Found"
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)