ソースを参照

Merge pull request #189 from gtmanfred/develop

move to make file and upstream python
Daniel Wallace 5 年 前
コミット
7d7b178d21
7 ファイル変更227 行追加52 行削除
  1. 17 15
      .travis.yml
  2. 11 0
      Makefile
  3. 179 0
      azure-pipelines.yml
  4. 0 19
      tests/Dockerfile
  5. 14 1
      tests/conftest.py
  6. 1 4
      tests/integration/test_clients.py
  7. 5 13
      tox.ini

+ 17 - 15
.travis.yml

@@ -1,16 +1,11 @@
+dist: xenial
 sudo: false
 services:
 - docker
 language: python
-cache: pip
 services:
 - docker
 
-before_install:
-- pyenv versions
-- pyenv version-name
-- env
-
 install:
 - pip install tox
 
@@ -19,21 +14,28 @@ python:
 - '3.4'
 - '3.5'
 - '3.6'
-- '3.7-dev'
+- '3.7'
+- '3.8-dev'
 
 env:
-- SALT=-v2018.3 BACKEND=-cherrypy CODECOV=py
-- SALT=-v2018.3 BACKEND=-tornado CODECOV=py
-- SALT=-v2019.2 BACKEND=-cherrypy CODECOV=py
-- SALT=-v2019.2 BACKEND=-tornado CODECOV=py
+- SALT=v2018.3 BACKEND=cherrypy
+- SALT=v2018.3 BACKEND=tornado
+- SALT=v2019.2 BACKEND=cherrypy
+- SALT=v2019.2 BACKEND=tornado
+- SALT=develop BACKEND=cherrypy
+- SALT=develop BACKEND=tornado
 
 matrix:
-  env:
+  allow_failures:
+  - python: '3.8-dev'
+  - env: SALT=develop BACKEND=tornado
+  - env: SALT=develop BACKEND=cherrypy
 
 script:
-- PYTHON="${TRAVIS_PYTHON_VERSION%-dev}"
-- docker run -v $PWD:/pepper -ti --rm gtmanfred/pepper:latest tox -c /pepper/tox.ini -e "${TRAVIS_PYTHON_VERSION%%.*}flake8,${CODECOV}${PYTHON//./}${BACKEND}${SALT}"
+- PYTHON="${TRAVIS_PYTHON_VERSION/-dev/-rc}"
+- TOX_VERSION="py${PYTHON//./}"
+- docker run -v $PWD:/pepper -ti --rm "python:$PYTHON" make -C /pepper test PYVERSION="${TOX_VERSION%-rc}" SALT="${SALT}" BACKEND="${BACKEND}"
 
 after_success:
 - sudo chown $USER .tox/
-- if [[ $CODECOV == "py" ]]; then tox -e codecov; fi
+- tox -e codecov

+ 11 - 0
Makefile

@@ -0,0 +1,11 @@
+PYVERSION?=py37
+SALT?=v2019.2
+BACKEND?=cherrypy
+DEBIAN_FRONTEND=noninteractive
+
+install:
+	apt update && apt install -y libc6-dev libffi-dev gcc git openssh-server libzmq3-dev
+	pip install tox
+
+test: install
+	tox -e flake8,$(PYVERSION)-$(BACKEND)-$(SALT)

+ 179 - 0
azure-pipelines.yml

@@ -0,0 +1,179 @@
+trigger:
+- develop
+
+jobs:
+
+- job: test_pepper
+  pool:
+    vmImage: 'Ubuntu-16.04'
+  strategy:
+    matrix:
+      py2.7-v2018.3-cherrypy:
+        python.version: '2.7'
+        version: py27
+        salt: v2018.3
+        backend: cherrypy
+      py2.7-v2019.2-cherrypy:
+        python.version: '2.7'
+        version: py27
+        salt: v2019.2
+        backend: cherrypy
+      py2.7-develop-cherrypy:
+        python.version: '2.7'
+        version: py27
+        salt: develop
+        backend: cherrypy
+      py2.7-v2018.3-tornado:
+        python.version: '2.7'
+        version: py27
+        salt: v2018.3
+        backend: tornado
+      py2.7-v2019.2-tornado:
+        python.version: '2.7'
+        version: py27
+        salt: v2019.2
+        backend: tornado
+      py2.7-develop-tornado:
+        python.version: '2.7'
+        version: py27
+        salt: develop
+        backend: tornado
+      py3.4-v2018.3-cherrypy:
+        python.version: '3.4'
+        version: py34
+        salt: v2018.3
+        backend: cherrypy
+      py3.4-v2019.2-cherrypy:
+        python.version: '3.4'
+        version: py34
+        salt: v2019.2
+        backend: cherrypy
+      py3.4-develop-cherrypy:
+        python.version: '3.4'
+        version: py34
+        salt: develop
+        backend: cherrypy
+      py3.4-v2018.3-tornado:
+        python.version: '3.4'
+        version: py34
+        salt: v2018.3
+        backend: tornado
+      py3.4-v2019.2-tornado:
+        python.version: '3.4'
+        version: py34
+        salt: v2019.2
+        backend: tornado
+      py3.4-develop-tornado:
+        python.version: '3.4'
+        version: py34
+        salt: develop
+        backend: tornado
+      py3.5-v2018.3-cherrypy:
+        python.version: '3.5'
+        version: py35
+        salt: v2018.3
+        backend: cherrypy
+      py3.5-v2019.2-cherrypy:
+        python.version: '3.5'
+        version: py35
+        salt: v2019.2
+        backend: cherrypy
+      py3.5-develop-cherrypy:
+        python.version: '3.5'
+        version: py35
+        salt: develop
+        backend: cherrypy
+      py3.5-v2018.3-tornado:
+        python.version: '3.5'
+        version: py35
+        salt: v2018.3
+        backend: tornado
+      py3.5-v2019.2-tornado:
+        python.version: '3.5'
+        version: py35
+        salt: v2019.2
+        backend: tornado
+      py3.5-develop-tornado:
+        python.version: '3.5'
+        version: py35
+        salt: develop
+        backend: tornado
+      py3.6-v2018.3-cherrypy:
+        python.version: '3.6'
+        version: py36
+        salt: v2018.3
+        backend: cherrypy
+      py3.6-v2019.2-cherrypy:
+        python.version: '3.6'
+        version: py36
+        salt: v2019.2
+        backend: cherrypy
+      py3.6-develop-cherrypy:
+        python.version: '3.6'
+        version: py36
+        salt: develop
+        backend: cherrypy
+      py3.6-v2018.3-tornado:
+        python.version: '3.6'
+        version: py36
+        salt: v2018.3
+        backend: tornado
+      py3.6-v2019.2-tornado:
+        python.version: '3.6'
+        version: py36
+        salt: v2019.2
+        backend: tornado
+      py3.6-develop-tornado:
+        python.version: '3.6'
+        version: py36
+        salt: develop
+        backend: tornado
+      py3.7-v2017.3-cherrypy:
+        python.version: '3.7'
+        version: py37
+        salt: v2017.3
+        backend: cherrypy
+      py3.7-v2019.2-cherrypy:
+        python.version: '3.7'
+        version: py37
+        salt: v2019.2
+        backend: cherrypy
+      py3.7-develop-cherrypy:
+        python.version: '3.7'
+        version: py37
+        salt: develop
+        backend: cherrypy
+      py3.7-v2017.3-tornado:
+        python.version: '3.7'
+        version: py37
+        salt: v2017.3
+        backend: tornado
+      py3.7-v2019.2-tornado:
+        python.version: '3.7'
+        version: py37
+        salt: v2019.2
+        backend: tornado
+      py3.7-develop-tornado:
+        python.version: '3.7'
+        version: py37
+        salt: develop
+        backend: tornado
+
+  steps:
+  - task: UsePythonVersion@0
+    inputs:
+      versionSpec: '$(python.version)'
+      architecture: x64
+
+  - script: |
+      pip install tox
+    displayName: Install dependencies
+  - script: |
+      docker run -v $PWD:/pepper --rm "python:$(python.version)" make -C /pepper test PYTHON_VERSION=$(version) SALT=$(salt) BACKEND=$(backend)
+    displayName: pytest
+  - script: |
+      sudo chown $USER .tox/
+      tox -e codecov
+    displayName: codecov
+    env:
+      CODECOV_TOKEN: '16c2a232-4329-438c-b163-ccbfeeab47aa'

+ 0 - 19
tests/Dockerfile

@@ -1,19 +0,0 @@
-FROM centos
-
-ENV PYENV_ROOT /usr/local/pyenv/
-ENV PATH /usr/local/pyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-
-RUN mkdir /usr/local/pyenv && \
-    yum install -y git openssh-server gcc readline-devel bzip2-devel zlib-devel openssl-devel sqlite-devel make libffi-devel && \
-    yum clean all && \
-    git clone git://github.com/yyuu/pyenv.git /usr/local/pyenv && \
-    git clone git://github.com/yyuu/pyenv-virtualenv.git /usr/local/pyenv/plugins/pyenv-virtualenv && \
-    ln -vs /usr/local/pyenv/bin/* /usr/local/pyenv/plugins/*/bin/* /usr/local/bin
-
-RUN pyenv install 2.7.15 && \
-    pyenv install 3.4.9  && \
-    pyenv install 3.5.6  && \
-    pyenv install 3.6.7  && \
-    pyenv install 3.7.1  && \
-    pyenv global 3.7.1 3.6.7 3.5.6 3.4.9 2.7.15 && \
-    pip install tox

+ 14 - 1
tests/conftest.py

@@ -2,6 +2,7 @@
 from __future__ import absolute_import, unicode_literals, print_function
 
 # Import python libraries
+import distutils.spawn
 import logging
 import os.path
 import shutil
@@ -10,6 +11,8 @@ import tempfile
 import textwrap
 
 # Import Salt Libraries
+import salt.client
+import salt.config
 import salt.utils.yaml as yaml
 
 # Import pytest libraries
@@ -26,6 +29,16 @@ DEFAULT_MINION_ID = 'pytest-salt-minion'
 log = logging.getLogger(__name__)
 
 
+@pytest.fixture(scope='session')
+def install_sshd_server():
+    if distutils.spawn.find_executable('sshd'):
+        return
+    __opts__ = salt.config.minion_config('tests/minion.conf')
+    __opts__['file_client'] = 'local'
+    caller = salt.client.Caller(mopts=__opts__)
+    caller.cmd('pkg.install', 'openssh-server')
+
+
 class SaltApi(SaltDaemonScriptBase):
     '''
     Class which runs the salt-api daemon
@@ -109,7 +122,7 @@ def output_file():
 
 
 @pytest.fixture(params=['/run', '/login'])
-def pepper_cli(request, session_salt_api, salt_api_port, output_file, session_sshd_server):
+def pepper_cli(request, session_salt_api, salt_api_port, output_file, install_sshd_server, session_sshd_server):
     '''
     Wrapper to invoke Pepper with common params and inside an empty env
     '''

+ 1 - 4
tests/integration/test_clients.py

@@ -35,10 +35,7 @@ def test_runner_client(pepper_cli):
 )
 def test_wheel_client_arg(pepper_cli, session_minion_id):
     ret = pepper_cli('--client=wheel', 'minions.connected')
-    # note - this seems not to work in returning session_minion_id with current runner, returning []
-    # the test originally was asserting the success atr but that isn't returned anymore
-    # further debugging needed with pytest-salt
-    assert ret == []
+    assert ret == ['pytest-session-salt-minion-0']
 
 
 @pytest.mark.xfail(

+ 5 - 13
tox.ini

@@ -1,5 +1,5 @@
 [tox]
-envlist = py{27,34,35,36}-{cherrypy,tornado}-{v2018.3,v2019.2},coverage,flake8
+envlist = py{27,34,35,36,37,38}-{cherrypy,tornado}-{v2018.3,v2019.2,develop},coverage,flake8
 skip_missing_interpreters = true
 skipsdist = false
 
@@ -13,18 +13,10 @@ deps = -r{toxinidir}/tests/requirements.txt
 changedir = {toxinidir}
 setenv = COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
 commands =
-    cherrypy: pytest --cov=pepper/ --cov-config=tox.ini --cov-report= {posargs} --salt-api-backend=rest_cherrypy
-    tornado: pytest --cov=pepper/ --cov-config=tox.ini --cov-report= {posargs} --salt-api-backend=rest_tornado
+    cherrypy: pytest -v --cov=pepper/ --cov-config=tox.ini --cov-report= {posargs} --salt-api-backend=rest_cherrypy
+    tornado: pytest -v --cov=pepper/ --cov-config=tox.ini --cov-report= {posargs} --salt-api-backend=rest_tornado
 
-[testenv:2flake8]
-basepython = python2
-deps =
-    -r {toxinidir}/tests/requirements.txt
-    flake8
-commands = flake8 tests/ pepper/ scripts/pepper setup.py
-
-[testenv:3flake8]
-basepython = python3
+[testenv:flake8]
 deps =
     -r {toxinidir}/tests/requirements.txt
     flake8
@@ -57,7 +49,7 @@ changedir = {toxinidir}/htmlcov
 commands = python -m http.server
 
 [pytest]
-addopts = --showlocals --log-file /tmp/pepper-runtests.log --no-print-logs -ra -sv
+addopts = --showlocals --log-file /tmp/pepper-runtests.log --no-print-logs -ra
 testpaths = tests
 norecursedirs = .git .tox
 usefixtures = pepperconfig