Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 42 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
---
sudo: required

services:
- docker

- docker
cache:
- pip

- pip
language: python

python:
- "2.7"
- "3.5"

- '2.7'
- '3.5'
env:
- TEST_SUITE=lint
- TEST_SUITE=functional OPENSHIFT_VERSION=latest
- TEST_SUITE=functional OPENSHIFT_VERSION=3.7
- TEST_SUITE=functional OPENSHIFT_VERSION=3.6
- TEST_SUITE=functional OPENSHIFT_VERSION=1.5
- TEST_SUITE=functional OPENSHIFT_VERSION=1.4
- TEST_SUITE=functional OPENSHIFT_VERSION=1.3

- TEST_SUITE=functional OPENSHIFT_VERSION=latest
- TEST_SUITE=functional OPENSHIFT_VERSION=3.7
- TEST_SUITE=functional OPENSHIFT_VERSION=3.6
- TEST_SUITE=functional OPENSHIFT_VERSION=1.5
- TEST_SUITE=functional OPENSHIFT_VERSION=1.4
- TEST_SUITE=functional OPENSHIFT_VERSION=1.3
script: tox
install:
- pip install tox-travis coveralls

script:
- tox

- pip install tox-travis coveralls
after_success:
- coveralls

before_cache:
- rm ~/.cache/pip/log/debug.log
- coveralls
jobs:
include:
- stage: lint
python: '2.7'
install:
- pip install tox-travis
script: tox -e py27-lint
env:
- TEST_SUITE=lint OPENSHIFT_VERSION=latest
- python: '3.5'
install:
- pip install tox-travis
script: tox -e py35-lint
env:
- TEST_SUITE=lint OPENSHIFT_VERSION=latest
- stage: deploy
script: skip
deploy:
provider: pypi
user: openshift
password:
secure: OtT8BL3rmSlag7H+jLNuPl52UOD8HVuohK0d4OQNMTiejZ1ali/fT4K1yCqteLLTalode1KnG/YpqQuOeEEVJCZNqbAeG3VuD4o3sx0hn1ATMwu5RDngovSSVojhKAOMSh/w3TycRysV+x/L5twntGycNUmtDiRGSJFmXGgq0EPLbE6DUv8IMwlhq/ncNz7/RU5KU852kwc6TDHZloHdhOH5ibibi7VCKUlkK/JnAT/OX0uw/j4v6Dvs6CzJ2lrSozUtjP5OxWPh6XRcXNxlxYuTSy7rjqBd05pk3YUAOQt/cEa4581Qu9hSEvhWFSJBjxpggWunTAbeSjqpdY+iqHcoKg+J3ErscIQnsLOwo8nCIKzyn4GMGx/jQYNfWuXGJiOqHFFCyYR16BajQ/gWk78K5MpUDlf2zoyq3NjTp7edY9lWWL7BEgZdd5EY6wI3V7tlGFeNG/iWw2gL3jR+FfUqzEnBnA+EfPUcowLD6rVCsKoxuLs1YyNiOJLzI1lX3FXvntEkVjPH7w5yju2GXWuw/Szgd0MK2HSedV/tp526V/GOkhD1sbQngEVdrIwPI1QbiMX/1pcSvkCvJrKq5EpShZ9iD/D0T92/01x5X3HSx+R3yV3zhB8L3H7RDL/F3HGNbqVPaj9rHAfTJaxWhy6Y3nWpfwQI43cKFCNwF28=
on:
tags: true
repo: openshift/openshift-restclient-python
stages:
- lint
- test
- deploy
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ def pytest_addoption(parser):


def pytest_report_header(config):
return "OpenShift verison: {}".format(config.getoption('--openshift-version'))
return "OpenShift version: {}".format(config.getoption('--openshift-version'))
5 changes: 5 additions & 0 deletions openshift/ansiblegen/examples/openshift_v1_route.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# v1_route.yml
---

# TODO(fabianvf): remove this limit when 3.6+ builds are working.
version_limits:
max: '1.5'
skip_latest: yes

tasks:
- create:
name: myroute
Expand Down
44 changes: 28 additions & 16 deletions test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
from __future__ import print_function

import re
import copy
import io
import os
import tarfile
import copy
import time
import uuid
import yaml
import socket
import tarfile
from contextlib import closing

import json
import docker
import pytest
import requests
import json

from pkg_resources import parse_version

Expand All @@ -26,17 +28,27 @@
os.remove(os.path.join(os.getcwd(), 'KubeObjHelper.log'))



@pytest.fixture(scope='session')
def port():
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.bind(('', 0))
return s.getsockname()[1]


@pytest.fixture(scope='session')
def openshift_container(request):
def openshift_container(request, port):
client = docker.from_env()
# TODO: bind to a random host port
openshift_version = request.config.getoption('--openshift-version')
if openshift_version is None:
yield None
else:
image_name = 'openshift/origin:{}'.format(openshift_version)
container = client.containers.run(image_name, 'start master', detach=True,
ports={'8443/tcp': 8443})
container = client.containers.run(
'openshift/origin:{}'.format(openshift_version),
'start master --listen=0.0.0.0:{}'.format(port),
detach=True,
ports={port: port}
)

try:
# Wait for the container to no longer be in the created state before
Expand All @@ -48,7 +60,7 @@ def openshift_container(request):
# Wait for the api server to be ready before continuing
for _ in range(10):
try:
requests.head("https://127.0.0.1:8443/healthz/ready", verify=False)
requests.head("https://127.0.0.1:{}/healthz/ready".format(port), verify=False)
except requests.RequestException:
pass
time.sleep(1)
Expand Down Expand Up @@ -105,15 +117,15 @@ def parse_test_name(name):


@pytest.fixture(scope='class')
def ansible_helper(request, kubeconfig, admin_kubeconfig):
def ansible_helper(request, kubeconfig, admin_kubeconfig, port):
api_version, resource = parse_test_name(request.node.name)
needs_admin = request.node.cls.tasks.get('admin')
config = admin_kubeconfig if needs_admin else kubeconfig
auth = {}
if kubeconfig is not None:
auth = {
'kubeconfig': str(config),
'host': 'https://localhost:8443',
'host': 'https://localhost:{}'.format(port),
'verify_ssl': False
}
try:
Expand Down Expand Up @@ -157,14 +169,14 @@ def compare_func(ansible_helper, k8s_obj, parameters):


@pytest.fixture(scope='class')
def namespace(kubeconfig):
def namespace(kubeconfig, port):
name = "test-{}".format(uuid.uuid4())

auth = {}
if kubeconfig is not None:
auth = {
'kubeconfig': str(kubeconfig),
'host': 'https://localhost:8443',
'host': 'https://localhost:{}'.format(port),
'verify_ssl': False
}
helper = KubernetesAnsibleModuleHelper('v1', 'namespace', debug=True, reset_logfile=False, **auth)
Expand All @@ -184,13 +196,13 @@ def object_name(request):


@pytest.fixture(scope='class')
def project(kubeconfig):
def project(kubeconfig, port):
name = "test-{}".format(uuid.uuid4())
auth = {}
if kubeconfig is not None:
auth = {
'kubeconfig': str(kubeconfig),
'host': 'https://localhost:8443',
'host': 'https://localhost:{}'.format(port),
'verify_ssl': False
}
helper = OpenShiftAnsibleModuleHelper('v1', 'project', debug=True, reset_logfile=False, **auth)
Expand Down Expand Up @@ -222,7 +234,7 @@ def skip_by_version(request, openshift_version):
if request.node.cls.tasks.get('version_limits') and openshift_version:
lowest_version = request.node.cls.tasks['version_limits'].get('min')
highest_version = request.node.cls.tasks['version_limits'].get('max')
skip_latest = request.node.cls.tasks['version_limits'].get('latest')
skip_latest = request.node.cls.tasks['version_limits'].get('skip_latest')

too_low = lowest_version and parse_version(lowest_version) > parse_version(openshift_version)
too_high = highest_version and parse_version(highest_version) < parse_version(openshift_version)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ commands =
docs: python setup.py build_sphinx
lint: flake8
unit: pytest openshift/test
functional: pytest test --openshift-version={env:openshift_version:latest}
functional: pytest test -v -r s --openshift-version={env:openshift_version:latest}

[testenv:update_client]
changedir = {toxinidir}/scripts
Expand Down