From d542318d63b847e4494a2688b091baeb5dbde1e1 Mon Sep 17 00:00:00 2001 From: Daniel Mizyrycki Date: Thu, 10 Oct 2013 17:46:09 -0700 Subject: testing infrastructure, issue #1766: Dockerize deployment of docker-ci --- .../docker-ci/functionaltests/test_index.py | 61 ++++++++++++++++++++++ .../docker-ci/functionaltests/test_registry.sh | 26 +++++++++ 2 files changed, 87 insertions(+) create mode 100755 hack/infrastructure/docker-ci/functionaltests/test_index.py create mode 100755 hack/infrastructure/docker-ci/functionaltests/test_registry.sh (limited to 'hack/infrastructure/docker-ci/functionaltests') diff --git a/hack/infrastructure/docker-ci/functionaltests/test_index.py b/hack/infrastructure/docker-ci/functionaltests/test_index.py new file mode 100755 index 0000000000..fd002c81e8 --- /dev/null +++ b/hack/infrastructure/docker-ci/functionaltests/test_index.py @@ -0,0 +1,61 @@ +#!/usr/bin/python + +import os +username, password = os.environ['DOCKER_CREDS'].split(':') + +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.support.ui import Select +from selenium.common.exceptions import NoSuchElementException +import unittest, time, re + +class Docker(unittest.TestCase): + def setUp(self): + self.driver = webdriver.PhantomJS() + self.driver.implicitly_wait(30) + self.base_url = "http://www.docker.io/" + self.verificationErrors = [] + self.accept_next_alert = True + + def test_docker(self): + driver = self.driver + print "Login into {0} as login user {1} ...".format(self.base_url,username) + driver.get(self.base_url + "/") + driver.find_element_by_link_text("INDEX").click() + driver.find_element_by_link_text("login").click() + driver.find_element_by_id("id_username").send_keys(username) + driver.find_element_by_id("id_password").send_keys(password) + print "Checking login user ..." + driver.find_element_by_css_selector("input[type=\"submit\"]").click() + try: self.assertEqual("test", driver.find_element_by_css_selector("h3").text) + except AssertionError as e: self.verificationErrors.append(str(e)) + print "Login user {0} found".format(username) + + def is_element_present(self, how, what): + try: self.driver.find_element(by=how, value=what) + except NoSuchElementException, e: return False + return True + + def is_alert_present(self): + try: self.driver.switch_to_alert() + except NoAlertPresentException, e: return False + return True + + def close_alert_and_get_its_text(self): + try: + alert = self.driver.switch_to_alert() + alert_text = alert.text + if self.accept_next_alert: + alert.accept() + else: + alert.dismiss() + return alert_text + finally: self.accept_next_alert = True + + def tearDown(self): + self.driver.quit() + self.assertEqual([], self.verificationErrors) + +if __name__ == "__main__": + unittest.main() diff --git a/hack/infrastructure/docker-ci/functionaltests/test_registry.sh b/hack/infrastructure/docker-ci/functionaltests/test_registry.sh new file mode 100755 index 0000000000..8bcd355c7c --- /dev/null +++ b/hack/infrastructure/docker-ci/functionaltests/test_registry.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -x + +# Cleanup +rm -rf docker-registry + +# Setup the environment +export SETTINGS_FLAVOR=test +export DOCKER_REGISTRY_CONFIG=config_test.yml + +# Get latest docker registry +git clone -q https://github.com/dotcloud/docker-registry.git +cd docker-registry + +# Get dependencies +pip install -q -r requirements.txt +pip install -q -r test-requirements.txt +pip install -q tox + +# Run registry tests +tox || exit 1 +export PYTHONPATH=$(pwd)/docker-registry +python -m unittest discover -p s3.py -s test || exit 1 +python -m unittest discover -p workflow.py -s test + -- cgit v1.2.1