diff --git a/.ci/docs b/.ci/docs index 186e254d1edd..7bf5d0a5b99d 100644 --- a/.ci/docs +++ b/.ci/docs @@ -1,65 +1,6 @@ -@Library('salt@1.1') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def global_timeout = 2 - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > 1) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - 1) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -def shell_header - -wrappedNode('docs', global_timeout, '#jenkins-prod-pr') { - - shell_header = '' - // Checkout the repo - stage('checkout-scm') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh shell_header + ''' - eval "$(pyenv init -)" - pyenv --version - pyenv install --skip-existing 3.6.8 - pyenv shell 3.6.8 - python --version - pip install -U nox-py2 - nox --version - ''' - } - - stage('Build HTML Docs') { - sh shell_header + ''' - eval "$(pyenv init -)" - pyenv shell 3.6.8 - nox -e 'docs-html(compress=True)' - ''' - archiveArtifacts artifacts: 'doc/html-archive.tar.gz' - } - - stage('Build Man Pages') { - sh shell_header + ''' - eval "$(pyenv init -)" - pyenv shell 3.6.8 - nox -e 'docs-man(compress=True, update=False)' - ''' - archiveArtifacts artifacts: 'doc/man-archive.tar.gz' - } -} +runDocs( + env: env) // vim: ft=groovy diff --git a/.ci/kitchen-amazon1-py2 b/.ci/kitchen-amazon1-py2 index 3e8d7e1742c5..1cc816c06ab2 100644 --- a/.ci/kitchen-amazon1-py2 +++ b/.ci/kitchen-amazon1-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'amazon' -def distro_version = '1' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'amazon', + distro_version: '1', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-amazon2-py2 b/.ci/kitchen-amazon2-py2 index 88f8153661ec..f4472174b64e 100644 --- a/.ci/kitchen-amazon2-py2 +++ b/.ci/kitchen-amazon2-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'amazon' -def distro_version = '2' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'amazon', + distro_version: '2', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-amazon2-py3 b/.ci/kitchen-amazon2-py3 index 0fc78adca2a2..27af6a0e9d78 100644 --- a/.ci/kitchen-amazon2-py3 +++ b/.ci/kitchen-amazon2-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'amazon' -def distro_version = '2' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'amazon', + distro_version: '2', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-archlts-py2 b/.ci/kitchen-archlts-py2 index bd418140e640..39d6b4d98d3d 100644 --- a/.ci/kitchen-archlts-py2 +++ b/.ci/kitchen-archlts-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'arch' -def distro_version = 'lts' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '-n integration.modules.test_pkg' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'arch', + distro_version: 'lts', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '-n integration.modules.test_pkg', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-archlts-py3 b/.ci/kitchen-archlts-py3 index 5cd76bdf33de..5d1b351582fe 100644 --- a/.ci/kitchen-archlts-py3 +++ b/.ci/kitchen-archlts-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'arch' -def distro_version = 'lts' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '-n integration.modules.test_pkg' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'arch', + distro_version: 'lts', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '-n integration.modules.test_pkg', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos6-py2 b/.ci/kitchen-centos6-py2 index 91e6568f54e2..73c912f52512 100644 --- a/.ci/kitchen-centos6-py2 +++ b/.ci/kitchen-centos6-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '6' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '6', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2 b/.ci/kitchen-centos7-py2 index 2409641bf05d..7cffd0c53e5d 100644 --- a/.ci/kitchen-centos7-py2 +++ b/.ci/kitchen-centos7-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2-cloud b/.ci/kitchen-centos7-py2-cloud index 3c1fa5d60d31..5a820da41efb 100644 --- a/.ci/kitchen-centos7-py2-cloud +++ b/.ci/kitchen-centos7-py2-cloud @@ -1,35 +1,17 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-cloud' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -runTests( +runTestSuite( + concurrent_builds: 0, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + kitchen_platforms_file: '/var/jenkins/workspace/nox-cloud-platforms.yml', + nox_env_name: 'runtests-cloud', + nox_passthrough_opts: '', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2-m2crypto b/.ci/kitchen-centos7-py2-m2crypto index 15108cca2ce8..014678f1c5a1 100644 --- a/.ci/kitchen-centos7-py2-m2crypto +++ b/.ci/kitchen-centos7-py2-m2crypto @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq-m2crypto' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-m2crypto', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2-proxy b/.ci/kitchen-centos7-py2-proxy index 300cb8f38ed5..9a7ef2cb5c8e 100644 --- a/.ci/kitchen-centos7-py2-proxy +++ b/.ci/kitchen-centos7-py2-proxy @@ -1,49 +1,17 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--proxy' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label, - extra_codecov_flags: ["proxy"]) + extra_codecov_flags: ["proxy"], + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--proxy', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2-pycryptodomex b/.ci/kitchen-centos7-py2-pycryptodomex index 1cd48f7751d3..9f1d59b6574c 100644 --- a/.ci/kitchen-centos7-py2-pycryptodomex +++ b/.ci/kitchen-centos7-py2-pycryptodomex @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq-pycryptodomex' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-pycryptodomex', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2-tcp b/.ci/kitchen-centos7-py2-tcp index 87531431067a..618d5fbb0af6 100644 --- a/.ci/kitchen-centos7-py2-tcp +++ b/.ci/kitchen-centos7-py2-tcp @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-tcp' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-tcp', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py2-tornado b/.ci/kitchen-centos7-py2-tornado index 37cdcbdee4bc..92835dfe99e2 100644 --- a/.ci/kitchen-centos7-py2-tornado +++ b/.ci/kitchen-centos7-py2-tornado @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py2' -def nox_env_name = 'runtests-tornado' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-tornado', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py3 b/.ci/kitchen-centos7-py3 index 3afa49d76d08..80c931c321db 100644 --- a/.ci/kitchen-centos7-py3 +++ b/.ci/kitchen-centos7-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py3-cloud b/.ci/kitchen-centos7-py3-cloud index 359901508883..0a01e58fd079 100644 --- a/.ci/kitchen-centos7-py3-cloud +++ b/.ci/kitchen-centos7-py3-cloud @@ -1,35 +1,17 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py3' -def nox_env_name = 'runtests-cloud' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -runTests( +runTestSuite( + concurrent_builds: 0, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + kitchen_platforms_file: '/var/jenkins/workspace/nox-cloud-platforms.yml', + nox_env_name: 'runtests-cloud', + nox_passthrough_opts: '', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py3-m2crypto b/.ci/kitchen-centos7-py3-m2crypto index 0b65d2ce7639..ac0727c8bc91 100644 --- a/.ci/kitchen-centos7-py3-m2crypto +++ b/.ci/kitchen-centos7-py3-m2crypto @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq-m2crypto' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-m2crypto', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py3-proxy b/.ci/kitchen-centos7-py3-proxy index 9bea26419550..69d521d1df9e 100644 --- a/.ci/kitchen-centos7-py3-proxy +++ b/.ci/kitchen-centos7-py3-proxy @@ -1,49 +1,17 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--proxy' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label, - extra_codecov_flags: ["proxy"]) + extra_codecov_flags: ["proxy"], + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--proxy', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py3-pycryptodomex b/.ci/kitchen-centos7-py3-pycryptodomex index ba49c10d9637..a4068b2dc638 100644 --- a/.ci/kitchen-centos7-py3-pycryptodomex +++ b/.ci/kitchen-centos7-py3-pycryptodomex @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq-pycryptodomex' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-pycryptodomex', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos7-py3-tcp b/.ci/kitchen-centos7-py3-tcp index 8a00b17b9331..acde7f88a07f 100644 --- a/.ci/kitchen-centos7-py3-tcp +++ b/.ci/kitchen-centos7-py3-tcp @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'centos' -def distro_version = '7' -def python_version = 'py3' -def nox_env_name = 'runtests-tcp' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '7', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-tcp', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-centos8-py3 b/.ci/kitchen-centos8-py3 new file mode 100644 index 000000000000..d4c8c7093d10 --- /dev/null +++ b/.ci/kitchen-centos8-py3 @@ -0,0 +1,16 @@ +@Library('salt@master-1.5') _ + +runTestSuite( + concurrent_builds: 1, + distro_name: 'centos', + distro_version: '8', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) + +// vim: ft=groovy diff --git a/.ci/kitchen-debian10-py3 b/.ci/kitchen-debian10-py3 index 3559ced2e36f..31c81a7fa7f1 100644 --- a/.ci/kitchen-debian10-py3 +++ b/.ci/kitchen-debian10-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'debian' -def distro_version = '10' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'debian', + distro_version: '10', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-debian8-py2 b/.ci/kitchen-debian8-py2 index 59700cf08534..c089fd2b4215 100644 --- a/.ci/kitchen-debian8-py2 +++ b/.ci/kitchen-debian8-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'debian' -def distro_version = '8' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'debian', + distro_version: '8', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-debian9-py2 b/.ci/kitchen-debian9-py2 index e0d223b697f9..535b4c2ba7be 100644 --- a/.ci/kitchen-debian9-py2 +++ b/.ci/kitchen-debian9-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'debian' -def distro_version = '9' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'debian', + distro_version: '9', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-debian9-py3 b/.ci/kitchen-debian9-py3 index 15288600e0d7..30f466805a65 100644 --- a/.ci/kitchen-debian9-py3 +++ b/.ci/kitchen-debian9-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'debian' -def distro_version = '9' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'debian', + distro_version: '9', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-fedora30-py2 b/.ci/kitchen-fedora30-py2 index eedb32c89052..fad0fbdf98a9 100644 --- a/.ci/kitchen-fedora30-py2 +++ b/.ci/kitchen-fedora30-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'fedora' -def distro_version = '30' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'fedora', + distro_version: '30', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-fedora30-py3 b/.ci/kitchen-fedora30-py3 index 0410dedf8d7b..ff62b85e45ad 100644 --- a/.ci/kitchen-fedora30-py3 +++ b/.ci/kitchen-fedora30-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'fedora' -def distro_version = '30' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'fedora', + distro_version: '30', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-fedora31-py3 b/.ci/kitchen-fedora31-py3 new file mode 100644 index 000000000000..803fe6ef97ab --- /dev/null +++ b/.ci/kitchen-fedora31-py3 @@ -0,0 +1,16 @@ +@Library('salt@master-1.5') _ + +runTestSuite( + concurrent_builds: 1, + distro_name: 'fedora', + distro_version: '31', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) + +// vim: ft=groovy diff --git a/.ci/kitchen-macosxhighsierra-py2 b/.ci/kitchen-macosxhighsierra-py2 index 524a427ac8d4..29a1cb0bb8bb 100644 --- a/.ci/kitchen-macosxhighsierra-py2 +++ b/.ci/kitchen-macosxhighsierra-py2 @@ -1,149 +1,20 @@ -@Library('salt@master-1.3') _ - -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 -// Now define a global pipeline timeout. This is the test run timeout with one(1) additional -// hour to allow for artifacts to be downloaded, if possible. -def global_timeout = testrun_timeout + 1; - -def distro_name = 'macosx' -def distro_version = 'highsierra' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def concurrent_builds = 1 -def jenkins_slave_label = 'kitchen-slave-mac' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -wrappedNode(jenkins_slave_label, global_timeout, '#jenkins-prod-pr') { - withEnv([ - 'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml', - 'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/verifier.yml', - 'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml', - "NOX_ENV_NAME=${nox_env_name}", - 'NOX_ENABLE_FROM_FILENAMES=true', - "NOX_PASSTHROUGH_OPTS=${nox_passthrough_opts}", - "GOLDEN_IMAGES_CI_BRANCH=${golden_images_branch}", - "PATH=/Users/parallels/.rbenv/shims:/Users/parallels/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/salt/bin:/usr/local/sbin", - 'RBENV_VERSION=2.6.3', - "TEST_SUITE=${python_version}", - "TEST_PLATFORM=${distro_name}-${distro_version}", - "FORCE_FULL=${params.runFull}", - ]) { - stage('VM Cleanup') { - sh ''' - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 86400) and (.State == "running"))|.ID'` - do - prlctl stop $i --kill - done - # don't delete vm's that haven't started yet ((.State == "stopped") and (.Uptime == "0")) - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 0) and (.State != "running"))|.ID'` - do - prlctl delete $i - done - ''' - } - // Checkout the repo - stage('Clone') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh 'bundle install --with vagrant macos --without ec2 windows opennebula docker' - } - - stage('Create VM') { - sh ''' - bundle exec kitchen create $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-create.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-create.log" - fi - """ - } - - try { - timeout(time: testrun_timeout, unit: 'HOURS') { - stage('Converge VM') { - sh ''' - ssh-agent /bin/bash -c 'ssh-add ~/.vagrant.d/insecure_private_key; bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"' - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-converge.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-converge.log" - fi - """ - } - stage('Run Tests') { - sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?";' - } - } - } finally { - try { - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-verify.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-verify.log" - fi - """ - archiveArtifacts( - artifacts: "artifacts/*,artifacts/**/*,.kitchen/logs/*-create.log,.kitchen/logs/*-converge.log,.kitchen/logs/*-verify.log,.kitchen/logs/*-download.log,artifacts/xml-unittests-output/*.xml", - allowEmptyArchive: true - ) - junit 'artifacts/xml-unittests-output/*.xml' - } finally { - stage('Cleanup') { - sh ''' - bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - } - stage('Upload Coverage') { - def distro_strings = [ - distro_name, - distro_version - ] - def report_strings = ( - [python_version] + nox_env_name.split('-') - ).flatten() - uploadCodeCoverage( - report_path: 'artifacts/coverage/coverage.xml', - report_name: "${distro_strings.join('-')}-${report_strings.join('-')}", - report_flags: ([distro_strings.join('')] + report_strings).flatten() - ) - } - } - } - } -} +@Library('salt@master-1.5') _ + +// Pre-nox pipeline +runTestSuite( + concurrent_builds: 1, + distro_name: 'macosx', + distro_version: 'highsierra', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave-mac', + kitchen_platforms_file: '/var/jenkins/workspace/pre-golden-nox-platforms.yml', + kitchen_verifier_file: '/var/jenkins/workspace/nox-verifier.yml', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '', + python_version: 'py2', + run_full: params.runFull, + testrun_timeout: 6, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-macosxhighsierra-py3 b/.ci/kitchen-macosxhighsierra-py3 index 2bca5234aaf5..55fdec3fabf3 100644 --- a/.ci/kitchen-macosxhighsierra-py3 +++ b/.ci/kitchen-macosxhighsierra-py3 @@ -1,149 +1,20 @@ -@Library('salt@master-1.3') _ - -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 -// Now define a global pipeline timeout. This is the test run timeout with one(1) additional -// hour to allow for artifacts to be downloaded, if possible. -def global_timeout = testrun_timeout + 1; - -def distro_name = 'macosx' -def distro_version = 'highsierra' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def concurrent_builds = 1 -def jenkins_slave_label = 'kitchen-slave-mac' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -wrappedNode(jenkins_slave_label, global_timeout, '#jenkins-prod-pr') { - withEnv([ - 'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml', - 'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/verifier.yml', - 'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml', - "NOX_ENV_NAME=${nox_env_name}", - 'NOX_ENABLE_FROM_FILENAMES=true', - "NOX_PASSTHROUGH_OPTS=${nox_passthrough_opts}", - "GOLDEN_IMAGES_CI_BRANCH=${golden_images_branch}", - "PATH=/Users/parallels/.rbenv/shims:/Users/parallels/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/salt/bin:/usr/local/sbin", - 'RBENV_VERSION=2.6.3', - "TEST_SUITE=${python_version}", - "TEST_PLATFORM=${distro_name}-${distro_version}", - "FORCE_FULL=${params.runFull}", - ]) { - stage('VM Cleanup') { - sh ''' - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 86400) and (.State == "running"))|.ID'` - do - prlctl stop $i --kill - done - # don't delete vm's that haven't started yet ((.State == "stopped") and (.Uptime == "0")) - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 0) and (.State != "running"))|.ID'` - do - prlctl delete $i - done - ''' - } - // Checkout the repo - stage('Clone') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh 'bundle install --with vagrant macos --without ec2 windows opennebula docker' - } - - stage('Create VM') { - sh ''' - bundle exec kitchen create $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-create.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-create.log" - fi - """ - } - - try { - timeout(time: testrun_timeout, unit: 'HOURS') { - stage('Converge VM') { - sh ''' - ssh-agent /bin/bash -c 'ssh-add ~/.vagrant.d/insecure_private_key; bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"' - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-converge.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-converge.log" - fi - """ - } - stage('Run Tests') { - sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?";' - } - } - } finally { - try { - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-verify.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-verify.log" - fi - """ - archiveArtifacts( - artifacts: "artifacts/*,artifacts/**/*,.kitchen/logs/*-create.log,.kitchen/logs/*-converge.log,.kitchen/logs/*-verify.log,.kitchen/logs/*-download.log,artifacts/xml-unittests-output/*.xml", - allowEmptyArchive: true - ) - junit 'artifacts/xml-unittests-output/*.xml' - } finally { - stage('Cleanup') { - sh ''' - bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - } - stage('Upload Coverage') { - def distro_strings = [ - distro_name, - distro_version - ] - def report_strings = ( - [python_version] + nox_env_name.split('-') - ).flatten() - uploadCodeCoverage( - report_path: 'artifacts/coverage/coverage.xml', - report_name: "${distro_strings.join('-')}-${report_strings.join('-')}", - report_flags: ([distro_strings.join('')] + report_strings).flatten() - ) - } - } - } - } -} +@Library('salt@master-1.5') _ + +// Pre-nox pipeline +runTestSuite( + concurrent_builds: 1, + distro_name: 'macosx', + distro_version: 'highsierra', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave-mac', + kitchen_platforms_file: '/var/jenkins/workspace/pre-golden-nox-platforms.yml', + kitchen_verifier_file: '/var/jenkins/workspace/nox-verifier.yml', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '', + python_version: 'py3', + run_full: params.runFull, + testrun_timeout: 6, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-macosxmojave-py2 b/.ci/kitchen-macosxmojave-py2 index 2b9af49b9ac5..370cc55dc1d3 100644 --- a/.ci/kitchen-macosxmojave-py2 +++ b/.ci/kitchen-macosxmojave-py2 @@ -1,149 +1,20 @@ -@Library('salt@master-1.3') _ - -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 -// Now define a global pipeline timeout. This is the test run timeout with one(1) additional -// hour to allow for artifacts to be downloaded, if possible. -def global_timeout = testrun_timeout + 1; - -def distro_name = 'macosx' -def distro_version = 'mojave' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def concurrent_builds = 1 -def jenkins_slave_label = 'kitchen-slave-mac' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -wrappedNode(jenkins_slave_label, global_timeout, '#jenkins-prod-pr') { - withEnv([ - 'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml', - 'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/verifier.yml', - 'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml', - "NOX_ENV_NAME=${nox_env_name}", - 'NOX_ENABLE_FROM_FILENAMES=true', - "NOX_PASSTHROUGH_OPTS=${nox_passthrough_opts}", - "GOLDEN_IMAGES_CI_BRANCH=${golden_images_branch}", - "PATH=/Users/parallels/.rbenv/shims:/Users/parallels/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/salt/bin:/usr/local/sbin", - 'RBENV_VERSION=2.6.3', - "TEST_SUITE=${python_version}", - "TEST_PLATFORM=${distro_name}-${distro_version}", - "FORCE_FULL=${params.runFull}", - ]) { - stage('VM Cleanup') { - sh ''' - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 86400) and (.State == "running"))|.ID'` - do - prlctl stop $i --kill - done - # don't delete vm's that haven't started yet ((.State == "stopped") and (.Uptime == "0")) - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 0) and (.State != "running"))|.ID'` - do - prlctl delete $i - done - ''' - } - // Checkout the repo - stage('Clone') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh 'bundle install --with vagrant macos --without ec2 windows opennebula docker' - } - - stage('Create VM') { - sh ''' - bundle exec kitchen create $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-create.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-create.log" - fi - """ - } - - try { - timeout(time: testrun_timeout, unit: 'HOURS') { - stage('Converge VM') { - sh ''' - ssh-agent /bin/bash -c 'ssh-add ~/.vagrant.d/insecure_private_key; bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"' - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-converge.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-converge.log" - fi - """ - } - stage('Run Tests') { - sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?";' - } - } - } finally { - try { - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-verify.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-verify.log" - fi - """ - archiveArtifacts( - artifacts: "artifacts/*,artifacts/**/*,.kitchen/logs/*-create.log,.kitchen/logs/*-converge.log,.kitchen/logs/*-verify.log,.kitchen/logs/*-download.log,artifacts/xml-unittests-output/*.xml", - allowEmptyArchive: true - ) - junit 'artifacts/xml-unittests-output/*.xml' - } finally { - stage('Cleanup') { - sh ''' - bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - } - stage('Upload Coverage') { - def distro_strings = [ - distro_name, - distro_version - ] - def report_strings = ( - [python_version] + nox_env_name.split('-') - ).flatten() - uploadCodeCoverage( - report_path: 'artifacts/coverage/coverage.xml', - report_name: "${distro_strings.join('-')}-${report_strings.join('-')}", - report_flags: ([distro_strings.join('')] + report_strings).flatten() - ) - } - } - } - } -} +@Library('salt@master-1.5') _ + +// Pre-nox pipeline +runTestSuite( + concurrent_builds: 1, + distro_name: 'macosx', + distro_version: 'mojave', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave-mac', + kitchen_platforms_file: '/var/jenkins/workspace/pre-golden-nox-platforms.yml', + kitchen_verifier_file: '/var/jenkins/workspace/nox-verifier.yml', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '', + python_version: 'py2', + run_full: params.runFull, + testrun_timeout: 6, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-macosxmojave-py3 b/.ci/kitchen-macosxmojave-py3 index 58fb949d2f44..e3ceca6090c3 100644 --- a/.ci/kitchen-macosxmojave-py3 +++ b/.ci/kitchen-macosxmojave-py3 @@ -1,149 +1,20 @@ -@Library('salt@master-1.3') _ - -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 -// Now define a global pipeline timeout. This is the test run timeout with one(1) additional -// hour to allow for artifacts to be downloaded, if possible. -def global_timeout = testrun_timeout + 1; - -def distro_name = 'macosx' -def distro_version = 'mojave' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def concurrent_builds = 1 -def jenkins_slave_label = 'kitchen-slave-mac' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -wrappedNode(jenkins_slave_label, global_timeout, '#jenkins-prod-pr') { - withEnv([ - 'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml', - 'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/verifier.yml', - 'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml', - "NOX_ENV_NAME=${nox_env_name}", - 'NOX_ENABLE_FROM_FILENAMES=true', - "NOX_PASSTHROUGH_OPTS=${nox_passthrough_opts}", - "GOLDEN_IMAGES_CI_BRANCH=${golden_images_branch}", - "PATH=/Users/parallels/.rbenv/shims:/Users/parallels/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/salt/bin:/usr/local/sbin", - 'RBENV_VERSION=2.6.3', - "TEST_SUITE=${python_version}", - "TEST_PLATFORM=${distro_name}-${distro_version}", - "FORCE_FULL=${params.runFull}", - ]) { - stage('VM Cleanup') { - sh ''' - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 86400) and (.State == "running"))|.ID'` - do - prlctl stop $i --kill - done - # don't delete vm's that haven't started yet ((.State == "stopped") and (.Uptime == "0")) - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 0) and (.State != "running"))|.ID'` - do - prlctl delete $i - done - ''' - } - // Checkout the repo - stage('Clone') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh 'bundle install --with vagrant macos --without ec2 windows opennebula docker' - } - - stage('Create VM') { - sh ''' - bundle exec kitchen create $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-create.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-create.log" - fi - """ - } - - try { - timeout(time: testrun_timeout, unit: 'HOURS') { - stage('Converge VM') { - sh ''' - ssh-agent /bin/bash -c 'ssh-add ~/.vagrant.d/insecure_private_key; bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"' - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-converge.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-converge.log" - fi - """ - } - stage('Run Tests') { - sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?";' - } - } - } finally { - try { - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-verify.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-verify.log" - fi - """ - archiveArtifacts( - artifacts: "artifacts/*,artifacts/**/*,.kitchen/logs/*-create.log,.kitchen/logs/*-converge.log,.kitchen/logs/*-verify.log,.kitchen/logs/*-download.log,artifacts/xml-unittests-output/*.xml", - allowEmptyArchive: true - ) - junit 'artifacts/xml-unittests-output/*.xml' - } finally { - stage('Cleanup') { - sh ''' - bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - } - stage('Upload Coverage') { - def distro_strings = [ - distro_name, - distro_version - ] - def report_strings = ( - [python_version] + nox_env_name.split('-') - ).flatten() - uploadCodeCoverage( - report_path: 'artifacts/coverage/coverage.xml', - report_name: "${distro_strings.join('-')}-${report_strings.join('-')}", - report_flags: ([distro_strings.join('')] + report_strings).flatten() - ) - } - } - } - } -} +@Library('salt@master-1.5') _ + +// Pre-nox pipeline +runTestSuite( + concurrent_builds: 1, + distro_name: 'macosx', + distro_version: 'mojave', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave-mac', + kitchen_platforms_file: '/var/jenkins/workspace/pre-golden-nox-platforms.yml', + kitchen_verifier_file: '/var/jenkins/workspace/nox-verifier.yml', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '', + python_version: 'py3', + run_full: params.runFull, + testrun_timeout: 6, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-macosxsierra-py2 b/.ci/kitchen-macosxsierra-py2 index 618b80b472cb..45b13915aa6b 100644 --- a/.ci/kitchen-macosxsierra-py2 +++ b/.ci/kitchen-macosxsierra-py2 @@ -1,149 +1,20 @@ -@Library('salt@master-1.3') _ - -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 -// Now define a global pipeline timeout. This is the test run timeout with one(1) additional -// hour to allow for artifacts to be downloaded, if possible. -def global_timeout = testrun_timeout + 1; - -def distro_name = 'macosx' -def distro_version = 'sierra' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def concurrent_builds = 1 -def jenkins_slave_label = 'kitchen-slave-mac' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -wrappedNode(jenkins_slave_label, global_timeout, '#jenkins-prod-pr') { - withEnv([ - 'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml', - 'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/verifier.yml', - 'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml', - "NOX_ENV_NAME=${nox_env_name}", - 'NOX_ENABLE_FROM_FILENAMES=true', - "NOX_PASSTHROUGH_OPTS=${nox_passthrough_opts}", - "GOLDEN_IMAGES_CI_BRANCH=${golden_images_branch}", - "PATH=/Users/parallels/.rbenv/shims:/Users/parallels/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/salt/bin:/usr/local/sbin", - 'RBENV_VERSION=2.6.3', - "TEST_SUITE=${python_version}", - "TEST_PLATFORM=${distro_name}-${distro_version}", - "FORCE_FULL=${params.runFull}", - ]) { - stage('VM Cleanup') { - sh ''' - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 86400) and (.State == "running"))|.ID'` - do - prlctl stop $i --kill - done - # don't delete vm's that haven't started yet ((.State == "stopped") and (.Uptime == "0")) - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 0) and (.State != "running"))|.ID'` - do - prlctl delete $i - done - ''' - } - // Checkout the repo - stage('Clone') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh 'bundle install --with vagrant macos --without ec2 windows opennebula docker' - } - - stage('Create VM') { - sh ''' - bundle exec kitchen create $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-create.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-create.log" - fi - """ - } - - try { - timeout(time: testrun_timeout, unit: 'HOURS') { - stage('Converge VM') { - sh ''' - ssh-agent /bin/bash -c 'ssh-add ~/.vagrant.d/insecure_private_key; bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"' - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-converge.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-converge.log" - fi - """ - } - stage('Run Tests') { - sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?";' - } - } - } finally { - try { - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-verify.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-verify.log" - fi - """ - archiveArtifacts( - artifacts: "artifacts/*,artifacts/**/*,.kitchen/logs/*-create.log,.kitchen/logs/*-converge.log,.kitchen/logs/*-verify.log,.kitchen/logs/*-download.log,artifacts/xml-unittests-output/*.xml", - allowEmptyArchive: true - ) - junit 'artifacts/xml-unittests-output/*.xml' - } finally { - stage('Cleanup') { - sh ''' - bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - } - stage('Upload Coverage') { - def distro_strings = [ - distro_name, - distro_version - ] - def report_strings = ( - [python_version] + nox_env_name.split('-') - ).flatten() - uploadCodeCoverage( - report_path: 'artifacts/coverage/coverage.xml', - report_name: "${distro_strings.join('-')}-${report_strings.join('-')}", - report_flags: ([distro_strings.join('')] + report_strings).flatten() - ) - } - } - } - } -} +@Library('salt@master-1.5') _ + +// Pre-nox pipeline +runTestSuite( + concurrent_builds: 1, + distro_name: 'macosx', + distro_version: 'sierra', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave-mac', + kitchen_platforms_file: '/var/jenkins/workspace/pre-golden-nox-platforms.yml', + kitchen_verifier_file: '/var/jenkins/workspace/nox-verifier.yml', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '', + python_version: 'py2', + run_full: params.runFull, + testrun_timeout: 6, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-macosxsierra-py3 b/.ci/kitchen-macosxsierra-py3 index ea285e299ba4..84d6bc295c03 100644 --- a/.ci/kitchen-macosxsierra-py3 +++ b/.ci/kitchen-macosxsierra-py3 @@ -1,149 +1,20 @@ -@Library('salt@master-1.3') _ - -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 -// Now define a global pipeline timeout. This is the test run timeout with one(1) additional -// hour to allow for artifacts to be downloaded, if possible. -def global_timeout = testrun_timeout + 1; - -def distro_name = 'macosx' -def distro_version = 'sierra' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '' -def concurrent_builds = 1 -def jenkins_slave_label = 'kitchen-slave-mac' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -wrappedNode(jenkins_slave_label, global_timeout, '#jenkins-prod-pr') { - withEnv([ - 'SALT_KITCHEN_PLATFORMS=/var/jenkins/workspace/platforms.yml', - 'SALT_KITCHEN_VERIFIER=/var/jenkins/workspace/verifier.yml', - 'SALT_KITCHEN_DRIVER=/var/jenkins/workspace/driver.yml', - "NOX_ENV_NAME=${nox_env_name}", - 'NOX_ENABLE_FROM_FILENAMES=true', - "NOX_PASSTHROUGH_OPTS=${nox_passthrough_opts}", - "GOLDEN_IMAGES_CI_BRANCH=${golden_images_branch}", - "PATH=/Users/parallels/.rbenv/shims:/Users/parallels/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/salt/bin:/usr/local/sbin", - 'RBENV_VERSION=2.6.3', - "TEST_SUITE=${python_version}", - "TEST_PLATFORM=${distro_name}-${distro_version}", - "FORCE_FULL=${params.runFull}", - ]) { - stage('VM Cleanup') { - sh ''' - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 86400) and (.State == "running"))|.ID'` - do - prlctl stop $i --kill - done - # don't delete vm's that haven't started yet ((.State == "stopped") and (.Uptime == "0")) - for i in `prlctl list -aij|jq -r '.[]|select((.Uptime|tonumber > 0) and (.State != "running"))|.ID'` - do - prlctl delete $i - done - ''' - } - // Checkout the repo - stage('Clone') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh 'bundle install --with vagrant macos --without ec2 windows opennebula docker' - } - - stage('Create VM') { - sh ''' - bundle exec kitchen create $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-create.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-create.log" - fi - """ - } - - try { - timeout(time: testrun_timeout, unit: 'HOURS') { - stage('Converge VM') { - sh ''' - ssh-agent /bin/bash -c 'ssh-add ~/.vagrant.d/insecure_private_key; bundle exec kitchen converge $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"' - ''' - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-converge.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-converge.log" - fi - """ - } - stage('Run Tests') { - sh 'bundle exec kitchen verify $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?";' - } - } - } finally { - try { - sh """ - if [ -s ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ]; then - mv ".kitchen/logs/${python_version}-${distro_name}-${distro_version}.log" ".kitchen/logs/${python_version}-${distro_name}-${distro_version}-verify.log" - fi - if [ -s ".kitchen/logs/kitchen.log" ]; then - mv ".kitchen/logs/kitchen.log" ".kitchen/logs/kitchen-verify.log" - fi - """ - archiveArtifacts( - artifacts: "artifacts/*,artifacts/**/*,.kitchen/logs/*-create.log,.kitchen/logs/*-converge.log,.kitchen/logs/*-verify.log,.kitchen/logs/*-download.log,artifacts/xml-unittests-output/*.xml", - allowEmptyArchive: true - ) - junit 'artifacts/xml-unittests-output/*.xml' - } finally { - stage('Cleanup') { - sh ''' - bundle exec kitchen destroy $TEST_SUITE-$TEST_PLATFORM; echo "ExitCode: $?"; - ''' - } - stage('Upload Coverage') { - def distro_strings = [ - distro_name, - distro_version - ] - def report_strings = ( - [python_version] + nox_env_name.split('-') - ).flatten() - uploadCodeCoverage( - report_path: 'artifacts/coverage/coverage.xml', - report_name: "${distro_strings.join('-')}-${report_strings.join('-')}", - report_flags: ([distro_strings.join('')] + report_strings).flatten() - ) - } - } - } - } -} +@Library('salt@master-1.5') _ + +// Pre-nox pipeline +runTestSuite( + concurrent_builds: 1, + distro_name: 'macosx', + distro_version: 'sierra', + env: env, + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave-mac', + kitchen_platforms_file: '/var/jenkins/workspace/pre-golden-nox-platforms.yml', + kitchen_verifier_file: '/var/jenkins/workspace/nox-verifier.yml', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '', + python_version: 'py3', + run_full: params.runFull, + testrun_timeout: 6, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-opensuse15-py2 b/.ci/kitchen-opensuse15-py2 index a923134e9403..46a638c7a4d3 100644 --- a/.ci/kitchen-opensuse15-py2 +++ b/.ci/kitchen-opensuse15-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'opensuse' -def distro_version = '15' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'opensuse', + distro_version: '15', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-opensuse15-py3 b/.ci/kitchen-opensuse15-py3 index 029f5bd8c045..2c993a8700f1 100644 --- a/.ci/kitchen-opensuse15-py3 +++ b/.ci/kitchen-opensuse15-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'opensuse' -def distro_version = '15' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'opensuse', + distro_version: '15', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py2 b/.ci/kitchen-ubuntu1604-py2 index 92b0fb003dbf..99263d9365c9 100644 --- a/.ci/kitchen-ubuntu1604-py2 +++ b/.ci/kitchen-ubuntu1604-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py2-m2crypto b/.ci/kitchen-ubuntu1604-py2-m2crypto index a10336c77d14..8fc5c4bd3509 100644 --- a/.ci/kitchen-ubuntu1604-py2-m2crypto +++ b/.ci/kitchen-ubuntu1604-py2-m2crypto @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq-m2crypto' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-m2crypto', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py2-proxy b/.ci/kitchen-ubuntu1604-py2-proxy index 767066b32bb9..939d322e6584 100644 --- a/.ci/kitchen-ubuntu1604-py2-proxy +++ b/.ci/kitchen-ubuntu1604-py2-proxy @@ -1,49 +1,17 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--proxy' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label, - extra_codecov_flags: ["proxy"]) + extra_codecov_flags: ["proxy"], + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--proxy', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py2-pycryptodomex b/.ci/kitchen-ubuntu1604-py2-pycryptodomex index ed153aa8315e..a56a5e0900d0 100644 --- a/.ci/kitchen-ubuntu1604-py2-pycryptodomex +++ b/.ci/kitchen-ubuntu1604-py2-pycryptodomex @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq-pycryptodomex' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-pycryptodomex', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py2-tcp b/.ci/kitchen-ubuntu1604-py2-tcp index f3dd44ecb5dc..cbd257e96417 100644 --- a/.ci/kitchen-ubuntu1604-py2-tcp +++ b/.ci/kitchen-ubuntu1604-py2-tcp @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py2' -def nox_env_name = 'runtests-tcp' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-tcp', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py2-tornado b/.ci/kitchen-ubuntu1604-py2-tornado index 318e89136d3c..1a67ef5b305d 100644 --- a/.ci/kitchen-ubuntu1604-py2-tornado +++ b/.ci/kitchen-ubuntu1604-py2-tornado @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py2' -def nox_env_name = 'runtests-tornado' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-tornado', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py3 b/.ci/kitchen-ubuntu1604-py3 index c4f1aeae90c9..935039216df4 100644 --- a/.ci/kitchen-ubuntu1604-py3 +++ b/.ci/kitchen-ubuntu1604-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py3-m2crypto b/.ci/kitchen-ubuntu1604-py3-m2crypto index b252781bc6db..b2a6c46d56e6 100644 --- a/.ci/kitchen-ubuntu1604-py3-m2crypto +++ b/.ci/kitchen-ubuntu1604-py3-m2crypto @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq-m2crypto' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-m2crypto', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py3-proxy b/.ci/kitchen-ubuntu1604-py3-proxy index 610c44086b45..7f329a368ff8 100644 --- a/.ci/kitchen-ubuntu1604-py3-proxy +++ b/.ci/kitchen-ubuntu1604-py3-proxy @@ -1,49 +1,17 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--proxy' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label, - extra_codecov_flags: ["proxy"]) + extra_codecov_flags: ["proxy"], + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--proxy', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py3-pycryptodomex b/.ci/kitchen-ubuntu1604-py3-pycryptodomex index 989233e66ae1..d02214fa69de 100644 --- a/.ci/kitchen-ubuntu1604-py3-pycryptodomex +++ b/.ci/kitchen-ubuntu1604-py3-pycryptodomex @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq-pycryptodomex' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq-pycryptodomex', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1604-py3-tcp b/.ci/kitchen-ubuntu1604-py3-tcp index 008309a22b4b..78a4d663fdbf 100644 --- a/.ci/kitchen-ubuntu1604-py3-tcp +++ b/.ci/kitchen-ubuntu1604-py3-tcp @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1604' -def python_version = 'py3' -def nox_env_name = 'runtests-tcp' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1604', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-tcp', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1804-py2 b/.ci/kitchen-ubuntu1804-py2 index ee2a7e58bb01..143d907de3a9 100644 --- a/.ci/kitchen-ubuntu1804-py2 +++ b/.ci/kitchen-ubuntu1804-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1804' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1804', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py2', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-ubuntu1804-py3 b/.ci/kitchen-ubuntu1804-py3 index 073be7c8c468..cdd2b77a99cc 100644 --- a/.ci/kitchen-ubuntu1804-py3 +++ b/.ci/kitchen-ubuntu1804-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 6 - -def distro_name = 'ubuntu' -def distro_version = '1804' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--ssh-tests' -def concurrent_builds = 1 -def use_spot_instances = true -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'ubuntu', + distro_version: '1804', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--ssh-tests', + python_version: 'py3', + testrun_timeout: 6, + use_spot_instances: true) // vim: ft=groovy diff --git a/.ci/kitchen-windows2016-py2 b/.ci/kitchen-windows2016-py2 index 8aa909d922b1..243abba8ed8d 100644 --- a/.ci/kitchen-windows2016-py2 +++ b/.ci/kitchen-windows2016-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 8 - -def distro_name = 'windows' -def distro_version = '2016' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--unit' -def concurrent_builds = 1 -def use_spot_instances = false -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'windows', + distro_version: '2016', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--unit', + python_version: 'py2', + testrun_timeout: 8, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-windows2016-py3 b/.ci/kitchen-windows2016-py3 index a7ec59965f63..5d1d811407e8 100644 --- a/.ci/kitchen-windows2016-py3 +++ b/.ci/kitchen-windows2016-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 8 - -def distro_name = 'windows' -def distro_version = '2016' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--unit' -def concurrent_builds = 1 -def use_spot_instances = false -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'windows', + distro_version: '2016', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--unit', + python_version: 'py3', + testrun_timeout: 8, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-windows2019-py2 b/.ci/kitchen-windows2019-py2 index 4c88d913b31d..a33e583f0fb8 100644 --- a/.ci/kitchen-windows2019-py2 +++ b/.ci/kitchen-windows2019-py2 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 8 - -def distro_name = 'windows' -def distro_version = '2019' -def python_version = 'py2' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--unit' -def concurrent_builds = 1 -def use_spot_instances = false -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'windows', + distro_version: '2019', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--unit', + python_version: 'py2', + testrun_timeout: 8, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/kitchen-windows2019-py3 b/.ci/kitchen-windows2019-py3 index de83da66810b..b69af1f118d2 100644 --- a/.ci/kitchen-windows2019-py3 +++ b/.ci/kitchen-windows2019-py3 @@ -1,48 +1,16 @@ -@Library('salt@master-1.3') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def testrun_timeout = 8 - -def distro_name = 'windows' -def distro_version = '2019' -def python_version = 'py3' -def nox_env_name = 'runtests-zeromq' -def golden_images_branch = 'master' -def nox_passthrough_opts = '--unit' -def concurrent_builds = 1 -def use_spot_instances = false -def jenkins_slave_label = 'kitchen-slave' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30')), - parameters([ - booleanParam(defaultValue: true, description: 'Run full test suite', name: 'runFull') - ]) -]) - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > concurrent_builds) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - concurrent_builds) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -runTests( +runTestSuite( + concurrent_builds: 1, + distro_name: 'windows', + distro_version: '2019', env: env, - distro_name: distro_name, - distro_version: distro_version, - python_version: python_version, - golden_images_branch: golden_images_branch, - nox_env_name: nox_env_name, - nox_passthrough_opts: nox_passthrough_opts, - testrun_timeout: testrun_timeout, - run_full: params.runFull, - use_spot_instances: use_spot_instances, - jenkins_slave_label: jenkins_slave_label) + golden_images_branch: 'master', + jenkins_slave_label: 'kitchen-slave', + nox_env_name: 'runtests-zeromq', + nox_passthrough_opts: '--unit', + python_version: 'py3', + testrun_timeout: 8, + use_spot_instances: false) // vim: ft=groovy diff --git a/.ci/lint b/.ci/lint index 48c4b7fb4b6c..2923e0bb6e17 100644 --- a/.ci/lint +++ b/.ci/lint @@ -1,184 +1,6 @@ -@Library('salt@1.1') _ +@Library('salt@master-1.5') _ -// Define the maximum time, in hours, that a test run should run for -def global_timeout = 3 -def salt_target_branch = 'master' - -properties([ - buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), -]) - -def shell_header - -// Only set milestones on PR builds -if (env.CHANGE_ID) { - // Be sure to cancel any previously running builds - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > 1) { - // This will cancel the previous build which also defined a matching milestone - milestone(buildNumber - 1) - } - // Define a milestone for this build so that, if another build starts, this one will be aborted - milestone(buildNumber) -} - -def lint_report_issues = [] - -wrappedNode('lint', global_timeout, '#jenkins-prod-pr') { - try { - shell_header = '' - - withEnv(["SALT_TARGET_BRANCH=${salt_target_branch}"]) { - // Checkout the repo - stage('checkout-scm') { - cleanWs notFailBuild: true - checkout scm - } - - // Setup the kitchen required bundle - stage('Setup') { - sh shell_header + ''' - # Need -M to detect renames otherwise they are reported as Delete and Add, need -C to detect copies, -C includes -M - # -M is on by default in git 2.9+ - git diff --name-status -l99999 -C "origin/${SALT_TARGET_BRANCH}" > file-list-status.log - # the -l increase the search limit, lets use awk so we do not need to repeat the search above. - gawk 'BEGIN {FS="\\t"} {if ($1 != "D") {print $NF}}' file-list-status.log > file-list-changed.log - gawk 'BEGIN {FS="\\t"} {if ($1 == "D") {print $NF}}' file-list-status.log > file-list-deleted.log - (git diff --name-status -l99999 -C "origin/${SALT_TARGET_BRANCH}" "origin/$BRANCH_NAME";echo "---";git diff --name-status -l99999 -C "origin/$BRANCH_NAME";printenv|grep -E '=[0-9a-z]{40,}+$|COMMIT=|BRANCH') > file-list-experiment.log - eval "$(pyenv init -)" - pyenv --version - pyenv install --skip-existing 2.7.15 - pyenv install --skip-existing 3.6.8 - pyenv shell 3.6.8 2.7.15 - python --version - pip3 install -U nox-py2 - nox --version - # Create the required virtualenvs in serial - nox --install-only -e lint-salt - nox --install-only -e lint-tests - ''' - } - archiveArtifacts( - artifacts: 'file-list-status.log,file-list-changed.log,file-list-deleted.log,file-list-experiment.log', - allowEmptyArchive: true - ) - } - - stage('Lint Changes') { - try { - parallel( - lintSalt: { - stage('Lint Salt Changes') { - if (readFile('file-list-changed.log') =~ /(?i)(^|\n)(salt\/.*\.py|setup\.py)\n/) { - sh shell_header + ''' - eval "$(pyenv init - --no-rehash)" - pyenv shell 3.6.8 2.7.15 - EC=254 - export PYLINT_REPORT=pylint-report-salt-chg.log - grep -Ei '^salt/.*\\.py$|^setup\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' nox -e lint-salt -- - EC=$? - exit $EC - ''' - } else { - // Always lint something so reporting doesn't fail - sh shell_header + ''' - eval "$(pyenv init - --no-rehash)" - pyenv shell 3.6.8 2.7.15 - EC=254 - export PYLINT_REPORT=pylint-report-salt-chg.log - nox -e lint-salt -- salt/ext/__init__.py - EC=$? - exit $EC - ''' - } - } - }, - lintTests: { - stage('Lint Test Changes') { - if (readFile('file-list-changed.log') =~ /(?i)(^|\n)tests\/.*\.py\n/) { - sh shell_header + ''' - eval "$(pyenv init - --no-rehash)" - pyenv shell 3.6.8 2.7.15 - EC=254 - export PYLINT_REPORT=pylint-report-tests-chg.log - grep -Ei '^tests/.*\\.py$' file-list-changed.log | xargs -r '--delimiter=\\n' nox -e lint-tests -- - EC=$? - exit $EC - ''' - } - } - } - ) - } finally { - def changed_logs_pattern = 'pylint-report-*-chg.log' - archiveArtifacts( - artifacts: changed_logs_pattern, - allowEmptyArchive: true - ) - lint_report_issues.add( - scanForIssues( - tool: pyLint(pattern: changed_logs_pattern, reportEncoding: 'UTF-8') - ) - ) - } - } - stage('Lint Full') { - if (env.CHANGE_BRANCH =~ /(?i)^merge[._-]/) { - // perform a full linit if this is a merge forward and the change only lint passed. - try { - parallel( - lintSaltFull: { - stage('Lint Salt Full') { - sh shell_header + ''' - eval "$(pyenv init - --no-rehash)" - pyenv shell 3.6.8 2.7.15 - EC=254 - export PYLINT_REPORT=pylint-report-salt-full.log - nox -e lint-salt - EC=$? - exit $EC - ''' - } - }, - lintTestsFull: { - stage('Lint Tests Full') { - sh shell_header + ''' - eval "$(pyenv init - --no-rehash)" - pyenv shell 3.6.8 2.7.15 - EC=254 - export PYLINT_REPORT=pylint-report-tests-full.log - nox -e lint-salt - EC=$? - exit $EC - ''' - } - } - ) - } finally { - def full_logs_pattern = 'pylint-report-*-full.log' - archiveArtifacts( - artifacts: full_logs_pattern, - allowEmptyArchive: true - ) - lint_report_issues.add( - scanForIssues( - tool: pyLint(pattern: full_logs_pattern, reportEncoding: 'UTF-8') - ) - ) - } - } - } - } finally { - publishIssues( - enabledForFailure: true, - aggregatingResults: true, - referenceJobName: "${salt_target_branch}/salt-${salt_target_branch}-lint", - qualityGates: [ - [threshold: 1, type: 'TOTAL', unstable: false] - ], - issues: lint_report_issues - ) - } -} +runLint( + env: env) // vim: ft=groovy diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd8f6999b136..0e976f71c1d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -265,3 +265,27 @@ repos: - -v - --py-version=3.7 - --platform=linux + + - repo: https://github.com/saltstack/salt-nox-pre-commit + rev: master + hooks: + - id: nox-py2 + alias: lint-salt + name: Lint Salt + files: ^((setup|noxfile)|salt/.*)\.py$ + args: + - -e + - lint-salt + - -- + + - repo: https://github.com/saltstack/salt-nox-pre-commit + rev: master + hooks: + - id: nox-py2 + alias: lint-tests + name: Lint Tests + files: ^tests/.*\.py$ + args: + - -e + - lint-tests + - -- diff --git a/doc/ref/engines/all/index.rst b/doc/ref/engines/all/index.rst index 15f6d8a667e0..d9b19e016666 100644 --- a/doc/ref/engines/all/index.rst +++ b/doc/ref/engines/all/index.rst @@ -11,7 +11,6 @@ engine modules :template: autosummary.rst.tmpl docker_events - hipchat http_logstash ircbot junos_syslog diff --git a/doc/ref/engines/all/salt.engines.hipchat.rst b/doc/ref/engines/all/salt.engines.hipchat.rst deleted file mode 100644 index 4b12b40f99b2..000000000000 --- a/doc/ref/engines/all/salt.engines.hipchat.rst +++ /dev/null @@ -1,6 +0,0 @@ -salt.engines.hipchat module -=========================== - -.. automodule:: salt.engines.hipchat - :members: - :undoc-members: diff --git a/doc/ref/modules/all/index.rst b/doc/ref/modules/all/index.rst index 94a42d8dad80..4fb32ea9b4c7 100644 --- a/doc/ref/modules/all/index.rst +++ b/doc/ref/modules/all/index.rst @@ -171,7 +171,6 @@ execution modules hashutil heat hg - hipchat hosts http ifttt diff --git a/doc/ref/modules/all/salt.modules.hipchat.rst b/doc/ref/modules/all/salt.modules.hipchat.rst deleted file mode 100644 index 09b519a3a93a..000000000000 --- a/doc/ref/modules/all/salt.modules.hipchat.rst +++ /dev/null @@ -1,6 +0,0 @@ -==================== -salt.modules.hipchat -==================== - -.. automodule:: salt.modules.hipchat - :members: diff --git a/doc/ref/modules/index.rst b/doc/ref/modules/index.rst index 73c47f168055..b19d91e1e8f8 100644 --- a/doc/ref/modules/index.rst +++ b/doc/ref/modules/index.rst @@ -298,7 +298,7 @@ prevent loading if dependencies are not met. Since ``__virtual__`` is called before the module is loaded, ``__salt__`` will be unreliable as not all modules will be available at this point in time. The -``__pillar`` and ``__grains__`` :ref:`"dunder" dictionaries ` +``__pillar__`` and ``__grains__`` :ref:`"dunder" dictionaries ` are available however. .. note:: diff --git a/doc/ref/returners/all/index.rst b/doc/ref/returners/all/index.rst index 9ee7a3b0b3d0..68831349e34c 100644 --- a/doc/ref/returners/all/index.rst +++ b/doc/ref/returners/all/index.rst @@ -19,7 +19,6 @@ returner modules elasticsearch_return etcd_return highstate_return - hipchat_return influxdb_return kafka_return librato_return diff --git a/doc/ref/returners/all/salt.returners.hipchat_return.rst b/doc/ref/returners/all/salt.returners.hipchat_return.rst deleted file mode 100644 index 37e5d6d4be11..000000000000 --- a/doc/ref/returners/all/salt.returners.hipchat_return.rst +++ /dev/null @@ -1,6 +0,0 @@ -============================= -salt.returners.hipchat_return -============================= - -.. automodule:: salt.returners.hipchat_return - :members: diff --git a/doc/ref/states/all/index.rst b/doc/ref/states/all/index.rst index f96f3c89bb29..e8c044d8a39d 100644 --- a/doc/ref/states/all/index.rst +++ b/doc/ref/states/all/index.rst @@ -115,7 +115,6 @@ state modules group heat hg - hipchat host http icinga2 diff --git a/doc/ref/states/all/salt.states.hipchat.rst b/doc/ref/states/all/salt.states.hipchat.rst deleted file mode 100644 index 921bd1bbe89a..000000000000 --- a/doc/ref/states/all/salt.states.hipchat.rst +++ /dev/null @@ -1,6 +0,0 @@ -=================== -salt.states.hipchat -=================== - -.. automodule:: salt.states.hipchat - :members: diff --git a/doc/topics/development/modules/index.rst b/doc/topics/development/modules/index.rst index 8c2771109f78..223e57ae484a 100644 --- a/doc/topics/development/modules/index.rst +++ b/doc/topics/development/modules/index.rst @@ -83,7 +83,7 @@ Sync Via the saltutil Module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The saltutil module has a number of functions that can be used to sync all -or specific dynamic modules. The ``saltutil.sync_*`` +or specific dynamic modules. The ``saltutil.sync_*`` :py:mod:`execution functions ` and :py:mod:`runner functions ` can be used to sync modules to minions and the master, respectively. @@ -120,7 +120,7 @@ This is done via setuptools entry points: ) Note that these are not synced from the Salt Master to the Minions. They must be -installed indepdendently on each Minion. +installed independently on each Minion. Module Types ============ @@ -139,7 +139,7 @@ Cache ``salt.cache`` (:ref:`index `) `` Cloud ``salt.cloud.clouds`` (:ref:`index `) ``clouds`` ``cloud_dirs`` Engine ``salt.engines`` (:ref:`index `) ``engines`` ``engines_dirs`` Execution ``salt.modules`` (:ref:`index `) ``modules`` ``module_dirs`` -Executor ``salt.executors`` (:ref:`index `) ``executors`` [#no-fs]_ ``executor_dirs`` +Executor ``salt.executors`` (:ref:`index `) ``executors`` ``executor_dirs`` File Server ``salt.fileserver`` (:ref:`index `) ``fileserver`` ``fileserver_dirs`` Grain ``salt.grains`` (:ref:`index `) ``grains`` ``grains_dirs`` Log Handler ``salt.log.handlers`` (:ref:`index `) ``log_handlers`` ``log_handlers_dirs`` diff --git a/doc/topics/grains/index.rst b/doc/topics/grains/index.rst index 106f0829cf92..8cfe7d1da978 100644 --- a/doc/topics/grains/index.rst +++ b/doc/topics/grains/index.rst @@ -63,8 +63,7 @@ Just add the option :conf_minion:`grains` and pass options to it: cab_u: 14-15 Then status data specific to your servers can be retrieved via Salt, or used -inside of the State system for matching. It also makes targeting, in the case -of the example above, simply based on specific data about your deployment. +inside of the State system for matching. It also makes it possible to target based on specific data about your deployment, as in the example above. Grains in /etc/salt/grains @@ -292,7 +291,7 @@ the Salt minion and provides the principal example of how to write grains: Syncing Grains ============== -Syncing grains can be done a number of ways, they are automatically synced when +Syncing grains can be done a number of ways. They are automatically synced when :mod:`state.highstate ` is called, or (as noted above) the grains can be manually synced and reloaded by calling the :mod:`saltutil.sync_grains ` or diff --git a/doc/topics/index.rst b/doc/topics/index.rst index 47656ebb4f87..4b9b80fc77aa 100644 --- a/doc/topics/index.rst +++ b/doc/topics/index.rst @@ -9,13 +9,13 @@ The 30 second summary Salt is: -* a configuration management system, capable of maintaining remote nodes - in defined states (for example, ensuring that specific packages are installed and - specific services are running) +* **A configuration management system.** Salt is capable of maintaining remote + nodes in defined states. For example, it can ensure that specific packages are + installed and that specific services are running. -* a distributed remote execution system used to execute commands and - query data on remote nodes, either individually or by arbitrary - selection criteria +* **A distributed remote execution system used to execute commands and + query data on remote nodes.** Salt can query and execute commands either on + individual nodes or by using an arbitrary selection criteria. It was developed in order to bring the best solutions found in the world of remote execution together and make them better, faster, and more @@ -188,4 +188,3 @@ documentation efforts, please review the :ref:`contributing documentation `! .. _`Apache 2.0 license`: http://www.apache.org/licenses/LICENSE-2.0.html - diff --git a/doc/topics/installation/freebsd.rst b/doc/topics/installation/freebsd.rst index e54e7fc67856..04aaf05cfc19 100644 --- a/doc/topics/installation/freebsd.rst +++ b/doc/topics/installation/freebsd.rst @@ -12,16 +12,22 @@ Salt is available in the FreeBSD ports tree at `sysutils/py-salt FreeBSD binary repo =================== +Install Salt via the official package repository. Salt is packaged both as a Python 2.7 or 3.6 version. + .. code-block:: bash pkg install py27-salt +.. code-block:: bash + + pkg install py36-salt + FreeBSD ports ============= -By default salt is packaged using python 2.7, but if you build your own packages from FreeBSD ports either by hand or with poudriere you can instead package it with your choice of python. Add a line to /etc/make.conf to choose your python flavour: +You can also build your own packages from FreeBSD ports either by hand or with poudriere you can instead package it with your choice of python. Add a line to /etc/make.conf to choose your python flavour: -.. code-block:: text +.. code-block:: bash echo "DEFAULT_VERSIONS+= python=3.6" >> /etc/make.conf diff --git a/doc/topics/jinja/index.rst b/doc/topics/jinja/index.rst index d8e12cf84d02..e3ac299fcd9f 100644 --- a/doc/topics/jinja/index.rst +++ b/doc/topics/jinja/index.rst @@ -770,7 +770,7 @@ Returns: .. versionadded:: 2017.7.0 -Return is a substring is found in a list of string values. +Return True if a substring is found in a list of string values. Example: diff --git a/doc/topics/releases/neon.rst b/doc/topics/releases/neon.rst index 75e91ef6e05f..aeb6e0030c34 100644 --- a/doc/topics/releases/neon.rst +++ b/doc/topics/releases/neon.rst @@ -4,7 +4,6 @@ Salt Release Notes - Codename Neon ================================== - Slot Syntax Updates =================== @@ -30,3 +29,35 @@ The slot syntax has been updated to support parsing dictionary responses and to Started: 09:59:58.623575 Duration: 1.229 ms Changes: + +Deprecations +============ + +Module Deprecations +------------------- + +- The hipchat module has been removed due to the service being retired. + :py:func:`Google Chat `, + :py:func:`MS Teams `, or + :py:func:`Slack ` may be suitable replacements. + + +State Deprecations +------------------ + +- The hipchat state has been removed due to the service being retired. + :py:func:`MS Teams ` or + :py:func:`Slack ` may be suitable replacements. + +Engine Removal +-------------- + +- The hipchat engine has been removed due to the service being retired. For users migrating + to Slack, the :py:func:`slack ` engine may be a suitable replacement. + +Returner Removal +---------------- + +- The hipchat returner has been removed due to the service being retired. For users migrating + to Slack, the :py:func:`slack ` returner may be a suitable + replacement. \ No newline at end of file diff --git a/noxfile.py b/noxfile.py index 2ffbd8284655..07f7c8f6e653 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,6 +5,7 @@ Nox configuration script ''' +# pylint: disable=resource-leakage # Import Python libs from __future__ import absolute_import, unicode_literals, print_function @@ -54,6 +55,9 @@ 'runtests-{}.log'.format(datetime.datetime.now().strftime('%Y%m%d%H%M%S.%f')) ) +# Prevent Python from writing bytecode +os.environ[str('PYTHONDONTWRITEBYTECODE')] = str('1') + def _create_ci_directories(): for dirname in ('logs', 'coverage', 'xml-unittests-output'): @@ -350,19 +354,23 @@ def _run_with_coverage(session, *test_cmd): python_path_entries.remove(SITECUSTOMIZE_DIR) python_path_entries.insert(0, SITECUSTOMIZE_DIR) python_path_env_var = os.pathsep.join(python_path_entries) + + env = { + # The updated python path so that sitecustomize is importable + 'PYTHONPATH': python_path_env_var, + # The full path to the .coverage data file. Makes sure we always write + # them to the same directory + 'COVERAGE_FILE': os.path.abspath(os.path.join(REPO_ROOT, '.coverage')), + # Instruct sub processes to also run under coverage + 'COVERAGE_PROCESS_START': os.path.join(REPO_ROOT, '.coveragerc') + } + if IS_DARWIN: + # Don't nuke our multiprocessing efforts objc! + # https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr + env['OBJC_DISABLE_INITIALIZE_FORK_SAFETY'] = 'YES' + try: - session.run( - *test_cmd, - env={ - # The updated python path so that sitecustomize is importable - 'PYTHONPATH': python_path_env_var, - # The full path to the .coverage data file. Makes sure we always write - # them to the same directory - 'COVERAGE_FILE': os.path.abspath(os.path.join(REPO_ROOT, '.coverage')), - # Instruct sub processes to also run under coverage - 'COVERAGE_PROCESS_START': os.path.join(REPO_ROOT, '.coveragerc') - } - ) + session.run(*test_cmd, env=env) finally: # Always combine and generate the XML coverage report try: @@ -394,7 +402,13 @@ def _runtests(session, coverage, cmd_args): if coverage is True: _run_with_coverage(session, 'coverage', 'run', os.path.join('tests', 'runtests.py'), *cmd_args) else: - session.run('python', os.path.join('tests', 'runtests.py'), *cmd_args) + cmd_args = ['python', os.path.join('tests', 'runtests.py')] + list(cmd_args) + env = None + if IS_DARWIN: + # Don't nuke our multiprocessing efforts objc! + # https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr + env = {'OBJC_DISABLE_INITIALIZE_FORK_SAFETY': 'YES'} + session.run(*cmd_args, env=env) except CommandFailed: # Disabling re-running failed tests for the time being raise @@ -845,11 +859,17 @@ def _pytest(session, coverage, cmd_args): # Create required artifacts directories _create_ci_directories() + env = None + if IS_DARWIN: + # Don't nuke our multiprocessing efforts objc! + # https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr + env = {'OBJC_DISABLE_INITIALIZE_FORK_SAFETY': 'YES'} + try: if coverage is True: _run_with_coverage(session, 'coverage', 'run', '-m', 'py.test', *cmd_args) else: - session.run('py.test', *cmd_args) + session.run('py.test', *cmd_args, env=env) except CommandFailed: # Re-run failed tests session.log('Re-running failed tests') @@ -857,7 +877,7 @@ def _pytest(session, coverage, cmd_args): if coverage is True: _run_with_coverage(session, 'coverage', 'run', '-m', 'py.test', *cmd_args) else: - session.run('py.test', *cmd_args) + session.run('py.test', *cmd_args, env=env) def _lint(session, rcfile, flags, paths): @@ -927,7 +947,7 @@ def lint_salt(session): if session.posargs: paths = session.posargs else: - paths = ['setup.py', 'salt/'] + paths = ['setup.py', 'noxfile.py', 'salt/'] _lint(session, '.testing.pylintrc', flags, paths) @@ -982,7 +1002,7 @@ def docs_html(session, compress): session.run('make', 'clean', external=True) session.run('make', 'html', 'SPHINXOPTS=-W', external=True) if compress: - session.run('tar', '-czvf', 'html-archive.tar.gz', '_build/html', external=True) + session.run('tar', '-cJvf', 'html-archive.tar.xz', '_build/html', external=True) os.chdir('..') @@ -1015,5 +1035,5 @@ def docs_man(session, compress, update): session.run('rm', '-rf', 'man/', external=True) session.run('cp', '-Rp', '_build/man', 'man/', external=True) if compress: - session.run('tar', '-czvf', 'man-archive.tar.gz', '_build/man', external=True) + session.run('tar', '-cJvf', 'man-archive.tar.xz', '_build/man', external=True) os.chdir('..') diff --git a/requirements/pytest.txt b/requirements/pytest.txt index 1159d1112959..9c0db5e96bfe 100644 --- a/requirements/pytest.txt +++ b/requirements/pytest.txt @@ -1,8 +1,6 @@ # PyTest -pytest >= 4.0.1 -pytest-cov -pytest-salt == 2018.12.8 -pytest-timeout >= 1.3.3 -pytest-tempdir >= 2018.8.11 -pytest-helpers-namespace >= 2017.11.11 -pytest-salt-runtests-bridge >= 2019.1.30 +pytest >=4.6.6,<4.7 # PyTest 4.6.x are the last Py2 and Py3 releases +pytest-salt >= 2019.11.27 +pytest-tempdir >= 2019.10.12 +pytest-helpers-namespace >= 2019.1.8 +pytest-salt-runtests-bridge >= 2019.7.10 diff --git a/requirements/static/darwin.in b/requirements/static/darwin.in index 7d6898dd9f9c..5061b007faff 100644 --- a/requirements/static/darwin.in +++ b/requirements/static/darwin.in @@ -14,7 +14,9 @@ kubernetes<4.0 mock>=3.0.5; python_version < '3.6' more-itertools==5.0.0 moto -pylxd>=2.2.5 +# XXX: Temporarily do not install pylxd. +# pylxd(or likely ws4py) will cause the test suite to hang at the finish line under runtests.py +# pylxd>=2.2.5 pyopenssl python-etcd>0.4.2 pyvmomi diff --git a/requirements/static/lint.in b/requirements/static/lint.in index a3e9e972e1ba..988a71dd494a 100644 --- a/requirements/static/lint.in +++ b/requirements/static/lint.in @@ -1,3 +1,3 @@ # Lint requirements pylint==1.6.5 -SaltPyLint>=v2017.3.6 +SaltPyLint>=v2019.11.14 diff --git a/requirements/static/py2.7/darwin.txt b/requirements/static/py2.7/darwin.txt index 59a9f5f0efea..9e12f1c36639 100644 --- a/requirements/static/py2.7/darwin.txt +++ b/requirements/static/py2.7/darwin.txt @@ -27,9 +27,9 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 click==7.0 clustershell==1.8.1 -contextlib2==0.5.5 # via cherrypy +configparser==4.0.2 # via importlib-metadata +contextlib2==0.5.5 # via cherrypy, importlib-metadata cookies==2.2.1 # via responses -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -47,6 +47,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -70,11 +71,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pbr==5.1.3 # via pylxd -pluggy==0.9.0 # via pytest +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -85,17 +86,15 @@ pycparser==2.19 # Next line explicitly commented out by pip-tools-compile because of the following regex: '^pycrypto==(.*)$' # pycrypto==2.6.1 ; sys_platform != "win32" pycryptodome==3.8.1 -pylxd==2.2.9 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -104,8 +103,6 @@ pytz==2019.1 # via moto, tempora pyvmomi==6.7.1.2018.12 pyyaml==5.1.2 pyzmq==18.0.1 ; python_version != "3.4" -requests-toolbelt==0.9.1 # via pylxd -requests-unixsocket==0.1.5 # via pylxd requests==2.21.0 responses==0.10.6 # via moto rfc3987==1.3.8 @@ -117,7 +114,7 @@ scp==0.13.2 # via junos-eznc selectors2==2.0.1 # via ncclient setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pylxd, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -125,16 +122,17 @@ supervisor==3.3.5 ; python_version < "3" tempora==1.14.1 # via portend timelib==0.2.4 tornado==4.5.3 ; python_version < "3" -urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests, requests-unixsocket +urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk -ws4py==0.5.1 # via pylxd xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py2.7/lint.txt b/requirements/static/py2.7/lint.txt index 078a544add4a..b831d2cb0803 100644 --- a/requirements/static/py2.7/lint.txt +++ b/requirements/static/py2.7/lint.txt @@ -6,7 +6,7 @@ # astroid==1.4.9 # via pylint backports.functools-lru-cache==1.5 # via isort, pylint -configparser==3.7.4 # via pylint +configparser==4.0.2 # via pylint futures==3.2.0 # via isort isort==4.3.17 # via pylint lazy-object-proxy==1.3.1 # via astroid @@ -14,6 +14,6 @@ mccabe==0.6.1 # via pylint modernize==0.5 # via saltpylint pycodestyle==2.5.0 # via saltpylint pylint==1.6.5 -saltpylint==2019.1.11 +saltpylint==2019.11.14 six==1.12.0 # via astroid, pylint wrapt==1.11.1 # via astroid diff --git a/requirements/static/py2.7/linux.txt b/requirements/static/py2.7/linux.txt index 3c46959fd755..e72c8bb69b69 100644 --- a/requirements/static/py2.7/linux.txt +++ b/requirements/static/py2.7/linux.txt @@ -25,9 +25,9 @@ cffi==1.12.2 chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 -contextlib2==0.5.5 # via cherrypy +configparser==4.0.2 # via importlib-metadata +contextlib2==0.5.5 # via cherrypy, importlib-metadata cookies==2.2.1 # via responses -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -45,6 +45,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via cryptography, docker, kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -66,10 +67,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -84,14 +86,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -112,7 +113,7 @@ selectors2==2.0.1 # via ncclient setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 supervisor==3.3.5 ; python_version < "3" @@ -122,8 +123,10 @@ tornado==4.5.3 ; python_version < "3" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py2.7/windows.txt b/requirements/static/py2.7/windows.txt index a50776715e80..94e4cce5f2e6 100644 --- a/requirements/static/py2.7/windows.txt +++ b/requirements/static/py2.7/windows.txt @@ -24,9 +24,9 @@ chardet==3.0.4 # via requests cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest -contextlib2==0.5.5 # via cherrypy +configparser==4.0.2 # via importlib-metadata +contextlib2==0.5.5 # via cherrypy, importlib-metadata cookies==2.2.1 # via responses -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -44,6 +44,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -64,10 +65,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -81,13 +83,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -108,7 +109,7 @@ scandir==1.10.0 # via pathlib2 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -119,6 +120,7 @@ tornado==4.5.3 ; python_version < "3" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -126,3 +128,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.4/linux.txt b/requirements/static/py3.4/linux.txt index 8351bb83b7d3..dafa99fa412f 100644 --- a/requirements/static/py3.4/linux.txt +++ b/requirements/static/py3.4/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -104,7 +104,7 @@ selectors2==2.0.1 # via ncclient setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -113,8 +113,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.5/darwin.txt b/requirements/static/py3.5/darwin.txt index a065e89c0cc0..62e17467da62 100644 --- a/requirements/static/py3.5/darwin.txt +++ b/requirements/static/py3.5/darwin.txt @@ -26,7 +26,6 @@ cherrypy==17.4.1 click==7.0 clustershell==1.8.1 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -41,6 +40,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -63,11 +63,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp pathlib2==2.3.3 # via pytest pathtools==0.1.2 # via watchdog -pbr==5.1.3 # via pylxd -pluggy==0.9.0 # via pytest +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -78,17 +78,15 @@ pycparser==2.19 # Next line explicitly commented out by pip-tools-compile because of the following regex: '^pycrypto==(.*)$' # pycrypto==2.6.1 ; sys_platform != "win32" pycryptodome==3.8.1 -pylxd==2.2.9 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -97,8 +95,6 @@ pytz==2019.1 # via moto, tempora pyvmomi==6.7.1.2018.12 pyyaml==5.1.2 pyzmq==18.0.1 ; python_version != "3.4" -requests-toolbelt==0.9.1 # via pylxd -requests-unixsocket==0.1.5 # via pylxd requests==2.21.0 responses==0.10.6 # via moto rfc3987==1.3.8 @@ -108,23 +104,24 @@ salttesting==2017.6.1 scp==0.13.2 # via junos-eznc setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pylxd, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 tempora==1.14.1 # via portend timelib==0.2.4 tornado==4.5.3 ; python_version >= "3.4" -urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests, requests-unixsocket +urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk -ws4py==0.5.1 # via pylxd xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py3.5/linux.txt b/requirements/static/py3.5/linux.txt index cd8d3c396e73..53251aba132d 100644 --- a/requirements/static/py3.5/linux.txt +++ b/requirements/static/py3.5/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 pathlib2==2.3.3 # via pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -102,7 +102,7 @@ scp==0.13.2 # via junos-eznc setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -111,8 +111,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.5/windows.txt b/requirements/static/py3.5/windows.txt index d56efcff653c..493c25317872 100644 --- a/requirements/static/py3.5/windows.txt +++ b/requirements/static/py3.5/windows.txt @@ -23,7 +23,6 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -38,6 +37,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -57,10 +57,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 pathlib2==2.3.3 # via pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -74,13 +75,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -100,7 +100,7 @@ salttesting==2017.6.1 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -110,6 +110,7 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -117,3 +118,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.6/darwin.txt b/requirements/static/py3.6/darwin.txt index 38979afc3bc9..fa85aee51004 100644 --- a/requirements/static/py3.6/darwin.txt +++ b/requirements/static/py3.6/darwin.txt @@ -26,7 +26,6 @@ cherrypy==17.4.1 click==7.0 clustershell==1.8.1 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -41,6 +40,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -63,10 +63,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp pathtools==0.1.2 # via watchdog -pbr==5.1.3 # via mock, pylxd -pluggy==0.9.0 # via pytest +pbr==5.1.3 # via mock +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -77,17 +78,15 @@ pycparser==2.19 # Next line explicitly commented out by pip-tools-compile because of the following regex: '^pycrypto==(.*)$' # pycrypto==2.6.1 ; sys_platform != "win32" pycryptodome==3.8.1 -pylxd==2.2.9 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -96,8 +95,6 @@ pytz==2019.1 # via moto, tempora pyvmomi==6.7.1.2018.12 pyyaml==5.1.2 pyzmq==18.0.1 ; python_version != "3.4" -requests-toolbelt==0.9.1 # via pylxd -requests-unixsocket==0.1.5 # via pylxd requests==2.21.0 responses==0.10.6 # via moto rfc3987==1.3.8 @@ -107,23 +104,24 @@ salttesting==2017.6.1 scp==0.13.2 # via junos-eznc setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pylxd, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 tempora==1.14.1 # via portend timelib==0.2.4 tornado==4.5.3 ; python_version >= "3.4" -urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests, requests-unixsocket +urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk -ws4py==0.5.1 # via pylxd xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py3.6/linux.txt b/requirements/static/py3.6/linux.txt index ffb3c0a9a2f1..d7ee75252cc5 100644 --- a/requirements/static/py3.6/linux.txt +++ b/requirements/static/py3.6/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -102,7 +102,7 @@ scp==0.13.2 # via junos-eznc setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -111,8 +111,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.6/windows.txt b/requirements/static/py3.6/windows.txt index 4a430b1b693f..ae3a3f462398 100644 --- a/requirements/static/py3.6/windows.txt +++ b/requirements/static/py3.6/windows.txt @@ -23,7 +23,6 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -38,6 +37,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -57,10 +57,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -74,13 +75,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -100,7 +100,7 @@ salttesting==2017.6.1 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -110,6 +110,7 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -117,3 +118,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.7/darwin.txt b/requirements/static/py3.7/darwin.txt index 401861d0d349..de86338b601e 100644 --- a/requirements/static/py3.7/darwin.txt +++ b/requirements/static/py3.7/darwin.txt @@ -26,7 +26,6 @@ cherrypy==17.4.1 click==7.0 clustershell==1.8.1 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -41,6 +40,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -63,10 +63,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp pathtools==0.1.2 # via watchdog -pbr==5.1.3 # via mock, pylxd -pluggy==0.9.0 # via pytest +pbr==5.1.3 # via mock +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -77,17 +78,15 @@ pycparser==2.19 # Next line explicitly commented out by pip-tools-compile because of the following regex: '^pycrypto==(.*)$' # pycrypto==2.6.1 ; sys_platform != "win32" pycryptodome==3.8.1 -pylxd==2.2.9 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -96,8 +95,6 @@ pytz==2019.1 # via moto, tempora pyvmomi==6.7.1.2018.12 pyyaml==5.1.2 pyzmq==18.0.1 ; python_version != "3.4" -requests-toolbelt==0.9.1 # via pylxd -requests-unixsocket==0.1.5 # via pylxd requests==2.21.0 responses==0.10.6 # via moto rfc3987==1.3.8 @@ -107,23 +104,24 @@ salttesting==2017.6.1 scp==0.13.2 # via junos-eznc setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pylxd, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 tempora==1.14.1 # via portend timelib==0.2.4 tornado==4.5.3 ; python_version >= "3.4" -urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests, requests-unixsocket +urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk -ws4py==0.5.1 # via pylxd xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py3.7/linux.txt b/requirements/static/py3.7/linux.txt index 0c4615c563a3..21049e3309f0 100644 --- a/requirements/static/py3.7/linux.txt +++ b/requirements/static/py3.7/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -102,7 +102,7 @@ scp==0.13.2 # via junos-eznc setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -111,8 +111,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.7/windows.txt b/requirements/static/py3.7/windows.txt index 97c1ee3ae971..bebcce92b36d 100644 --- a/requirements/static/py3.7/windows.txt +++ b/requirements/static/py3.7/windows.txt @@ -23,7 +23,6 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -38,6 +37,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -57,10 +57,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -74,13 +75,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -100,7 +100,7 @@ salttesting==2017.6.1 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -110,6 +110,7 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -117,3 +118,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/salt/_logging/handlers.py b/salt/_logging/handlers.py index 6df8d4530b83..65e2cc427051 100644 --- a/salt/_logging/handlers.py +++ b/salt/_logging/handlers.py @@ -244,7 +244,7 @@ def emit(self, record): elif sys.version_info < (3, 7): # On python versions lower than 3.7, we sill subclass and overwrite prepare to include the fix for: # https://bugs.python.org/issue35726 - class QueueHandler(ExcInfoOnLogLevelFormatMixin, logging.handlers.QueueHandler): # pylint: disable=no-member + class QueueHandler(ExcInfoOnLogLevelFormatMixin, logging.handlers.QueueHandler): # pylint: disable=no-member,inconsistent-mro def __init__(self, queue): super(QueueHandler, self).__init__(queue) @@ -297,7 +297,7 @@ def prepare(self, record): record.exc_text = None return record else: - class QueueHandler(ExcInfoOnLogLevelFormatMixin, logging.handlers.QueueHandler): # pylint: disable=no-member + class QueueHandler(ExcInfoOnLogLevelFormatMixin, logging.handlers.QueueHandler): # pylint: disable=no-member,inconsistent-mro def __init__(self, queue): super(QueueHandler, self).__init__(queue) diff --git a/salt/_logging/impl.py b/salt/_logging/impl.py index a134486a3ec3..347259bcf506 100644 --- a/salt/_logging/impl.py +++ b/salt/_logging/impl.py @@ -121,9 +121,9 @@ class __StoreLoggingHandler(TemporaryLoggingHandler): class SaltLogRecord(logging.LogRecord): def __init__(self, *args, **kwargs): logging.LogRecord.__init__(self, *args, **kwargs) - self.bracketname = '[{:<17}]'.format(self.name) - self.bracketlevel = '[{:<8}]'.format(self.levelname) - self.bracketprocess = '[{:>5}]'.format(self.process) + self.bracketname = '[{:<17}]'.format(str(self.name)) + self.bracketlevel = '[{:<8}]'.format(str(self.levelname)) + self.bracketprocess = '[{:>5}]'.format(str(self.process)) class SaltColorLogRecord(SaltLogRecord): @@ -241,7 +241,7 @@ def __new__(cls, *args): def _log(self, level, msg, args, exc_info=None, extra=None, # pylint: disable=arguments-differ stack_info=False, - stack_level=1, + stacklevel=1, exc_info_on_loglevel=None): if extra is None: extra = {} @@ -290,7 +290,7 @@ def _log(self, level, msg, args, exc_info=None, else: LOGGING_LOGGER_CLASS._log( self, level, msg, args, exc_info=exc_info, extra=extra, - stack_info=stack_info, stack_level=stack_level + stack_info=stack_info, stacklevel=stacklevel ) def makeRecord(self, name, level, fn, lno, msg, args, exc_info, diff --git a/salt/beacons/inotify.py b/salt/beacons/inotify.py index da68b6ab5743..e3bfe4eb8947 100644 --- a/salt/beacons/inotify.py +++ b/salt/beacons/inotify.py @@ -117,6 +117,10 @@ def validate(config): if 'files' not in _config: return False, 'Configuration for inotify beacon must include files.' else: + if not isinstance(_config['files'], dict): + return False, ('Configuration for inotify beacon invalid, ' + 'files must be a dict.') + for path in _config.get('files'): if not isinstance(_config['files'][path], dict): diff --git a/salt/client/mixins.py b/salt/client/mixins.py index bff6a1c3e1ce..bd093e9ad1d4 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -510,6 +510,7 @@ def asynchronous(self, fun, low, user='UNKNOWN', pub=None): async_pub = pub if pub is not None else self._gen_async_pub() proc = salt.utils.process.SignalHandlingProcess( target=self._proc_function, + name='ProcessFunc', args=(fun, low, user, async_pub['tag'], async_pub['jid'])) with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM): # Reset current signals before starting the process in diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 3180ded3ed6b..b2f4350c57f9 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -36,6 +36,7 @@ import salt.syspaths import salt.exceptions import salt.defaults.exitcodes +import salt.utils.immutabletypes as immutabletypes try: import psutil @@ -100,11 +101,7 @@ def _gather_buffer_space(): # TODO: Reserved for future use _DFLT_IPC_RBUFFER = _gather_buffer_space() * .5 -FLO_DIR = os.path.join( - os.path.dirname(os.path.dirname(__file__)), - 'daemons', 'flo') - -VALID_OPTS = { +VALID_OPTS = immutabletypes.freeze({ # The address of the salt master. May be specified as IP address or hostname 'master': (six.string_types, list), @@ -1194,10 +1191,10 @@ def _gather_buffer_space(): # Thorium top file location 'thorium_top': six.string_types, -} +}) # default configurations -DEFAULT_MINION_OPTS = { +DEFAULT_MINION_OPTS = immutabletypes.freeze({ 'interface': '0.0.0.0', 'master': 'salt', 'master_type': 'str', @@ -1489,9 +1486,9 @@ def _gather_buffer_space(): 'discovery': False, 'schedule': {}, 'ssh_merge_pillar': True -} +}) -DEFAULT_MASTER_OPTS = { +DEFAULT_MASTER_OPTS = immutabletypes.freeze({ 'interface': '0.0.0.0', 'publish_port': 4505, 'zmq_backlog': 1000, @@ -1816,12 +1813,12 @@ def _gather_buffer_space(): 'auth_events': True, 'minion_data_cache_events': True, 'enable_ssh_minions': False, -} +}) # ----- Salt Proxy Minion Configuration Defaults -----------------------------------> # These are merged with DEFAULT_MINION_OPTS since many of them also apply here. -DEFAULT_PROXY_MINION_OPTS = { +DEFAULT_PROXY_MINION_OPTS = immutabletypes.freeze({ 'conf_file': os.path.join(salt.syspaths.CONFIG_DIR, 'proxy'), 'log_file': os.path.join(salt.syspaths.LOGS_DIR, 'proxy'), 'add_proxymodule_to_opts': False, @@ -1847,9 +1844,10 @@ def _gather_buffer_space(): 'pki_dir': os.path.join(salt.syspaths.CONFIG_DIR, 'pki', 'proxy'), 'cachedir': os.path.join(salt.syspaths.CACHE_DIR, 'proxy'), 'sock_dir': os.path.join(salt.syspaths.SOCK_DIR, 'proxy'), -} +}) + # ----- Salt Cloud Configuration Defaults -----------------------------------> -DEFAULT_CLOUD_OPTS = { +DEFAULT_CLOUD_OPTS = immutabletypes.freeze({ 'verify_env': True, 'default_include': 'cloud.conf.d/*.conf', # Global defaults @@ -1877,17 +1875,17 @@ def _gather_buffer_space(): 'log_rotate_backup_count': 0, 'bootstrap_delay': None, 'cache': 'localfs', -} +}) -DEFAULT_API_OPTS = { +DEFAULT_API_OPTS = immutabletypes.freeze({ # ----- Salt master settings overridden by Salt-API ---------------------> 'api_pidfile': os.path.join(salt.syspaths.PIDFILE_DIR, 'salt-api.pid'), 'api_logfile': os.path.join(salt.syspaths.LOGS_DIR, 'api'), 'rest_timeout': 300, # <---- Salt master settings overridden by Salt-API ---------------------- -} +}) -DEFAULT_SPM_OPTS = { +DEFAULT_SPM_OPTS = immutabletypes.freeze({ # ----- Salt master settings overridden by SPM ---------------------> 'spm_conf_file': os.path.join(salt.syspaths.CONFIG_DIR, 'spm'), 'formula_path': salt.syspaths.SPM_FORMULA_PATH, @@ -1908,15 +1906,15 @@ def _gather_buffer_space(): 'spm_node_type': '', 'spm_share_dir': os.path.join(salt.syspaths.SHARE_DIR, 'spm'), # <---- Salt master settings overridden by SPM ---------------------- -} +}) -VM_CONFIG_DEFAULTS = { +VM_CONFIG_DEFAULTS = immutabletypes.freeze({ 'default_include': 'cloud.profiles.d/*.conf', -} +}) -PROVIDER_CONFIG_DEFAULTS = { +PROVIDER_CONFIG_DEFAULTS = immutabletypes.freeze({ 'default_include': 'cloud.providers.d/*.conf', -} +}) # <---- Salt Cloud Configuration Defaults ------------------------------------ @@ -2460,10 +2458,10 @@ def syndic_config(master_config_path, master_defaults=None): if minion_defaults is None: - minion_defaults = DEFAULT_MINION_OPTS + minion_defaults = DEFAULT_MINION_OPTS.copy() if master_defaults is None: - master_defaults = DEFAULT_MASTER_OPTS + master_defaults = DEFAULT_MASTER_OPTS.copy() opts = {} master_opts = master_config( @@ -2782,7 +2780,7 @@ def apply_cloud_config(overrides, defaults=None): Return a cloud config ''' if defaults is None: - defaults = DEFAULT_CLOUD_OPTS + defaults = DEFAULT_CLOUD_OPTS.copy() config = defaults.copy() if overrides: @@ -3682,7 +3680,7 @@ def apply_minion_config(overrides=None, Returns minion configurations dict. ''' if defaults is None: - defaults = DEFAULT_MINION_OPTS + defaults = DEFAULT_MINION_OPTS.copy() if overrides is None: overrides = {} @@ -3837,7 +3835,7 @@ def master_config(path, env_var='SALT_MASTER_CONFIG', defaults=None, exit_on_con :py:func:`salt.client.client_config`. ''' if defaults is None: - defaults = DEFAULT_MASTER_OPTS + defaults = DEFAULT_MASTER_OPTS.copy() if not os.environ.get(env_var, None): # No valid setting was given using the configuration variable. @@ -3879,7 +3877,7 @@ def apply_master_config(overrides=None, defaults=None): Returns master configurations dict. ''' if defaults is None: - defaults = DEFAULT_MASTER_OPTS + defaults = DEFAULT_MASTER_OPTS.copy() if overrides is None: overrides = {} @@ -4054,7 +4052,7 @@ def client_config(path, env_var='SALT_CLIENT_CONFIG', defaults=None): :py:class:`~salt.client.LocalClient`. ''' if defaults is None: - defaults = DEFAULT_MASTER_OPTS + defaults = DEFAULT_MASTER_OPTS.copy() xdg_dir = salt.utils.xdg.xdg_config_dir() if os.path.isdir(xdg_dir): @@ -4122,10 +4120,10 @@ def api_config(path): need to be stubbed out for salt-api ''' # Let's grab a copy of salt-api's required defaults - opts = DEFAULT_API_OPTS + opts = DEFAULT_API_OPTS.copy() # Let's override them with salt's master opts - opts.update(client_config(path, defaults=DEFAULT_MASTER_OPTS)) + opts.update(client_config(path, defaults=DEFAULT_MASTER_OPTS.copy())) # Let's set the pidfile and log_file values in opts to api settings opts.update({ diff --git a/salt/engines/hipchat.py b/salt/engines/hipchat.py deleted file mode 100644 index d25e428e72ea..000000000000 --- a/salt/engines/hipchat.py +++ /dev/null @@ -1,429 +0,0 @@ -# -*- coding: utf-8 -*- -''' -An engine that reads messages from Hipchat and sends them to the Salt -event bus. Alternatively Salt commands can be sent to the Salt master -via Hipchat by setting the control parameter to ``True`` and using command -prefaced with a ``!``. Only token key is required, but room and control -keys make the engine interactive. - -.. versionadded: 2016.11.0 - -:depends: hypchat -:configuration: Example configuration - - .. code-block:: yaml - - engines: - - hipchat: - api_url: http://api.hipchat.myteam.com - token: 'XXXXXX' - room: 'salt' - control: True - valid_users: - - SomeUser - valid_commands: - - test.ping - - cmd.run - - list_jobs - - list_commands - aliases: - list_jobs: - cmd: jobs.list_jobs - list_commands: - cmd: pillar.get salt:engines:hipchat:valid_commands target=saltmaster - max_rooms: 0 - wait_time: 1 -''' - -from __future__ import absolute_import, print_function, unicode_literals -import logging -import time -import os - - -try: - import hypchat -except ImportError: - hypchat = None - -import salt.utils.args -import salt.utils.event -import salt.utils.files -import salt.utils.http -import salt.utils.json -import salt.utils.stringutils -import salt.runner -import salt.client -import salt.loader -import salt.output -from salt.ext import six - -log = logging.getLogger(__name__) - -_DEFAULT_API_URL = 'https://api.hipchat.com' -_DEFAULT_SLEEP = 5 -_DEFAULT_MAX_ROOMS = 1000 - -__virtualname__ = 'hipchat' - - -def __virtual__(): - return __virtualname__ if hypchat is not None \ - else (False, 'hypchat is not installed') - - -def _publish_file(token, room, filepath, message='', outputter=None, api_url=None): - ''' - Send file to a HipChat room via API version 2 - - Parameters - ---------- - token : str - HipChat API version 2 compatible token - must be token for active user - room: str - Name or API ID of the room to notify - filepath: str - Full path of file to be sent - message: str, optional - Message to send to room - api_url: str, optional - Hipchat API URL to use, defaults to http://api.hipchat.com - ''' - - if not os.path.isfile(filepath): - raise ValueError("File '{0}' does not exist".format(filepath)) - if len(message) > 1000: - raise ValueError('Message too long') - - url = "{0}/v2/room/{1}/share/file".format(api_url, room) - headers = {'Content-type': 'multipart/related; boundary=boundary123456'} - headers['Authorization'] = "Bearer " + token - msg = salt.utils.json.dumps({'message': message}) - - # future lint: disable=blacklisted-function - with salt.utils.files.fopen(filepath, 'rb') as rfh: - payload = str('''\ ---boundary123456 -Content-Type: application/json; charset=UTF-8 -Content-Disposition: attachment; name="metadata" - -{0} - ---boundary123456 -Content-Disposition: attachment; name="file"; filename="{1}" - -{2} - ---boundary123456--\ -''').format(msg, - os.path.basename(salt.utils.stringutils.to_str(filepath)), - salt.utils.stringutils.to_str(rfh.read())) - # future lint: enable=blacklisted-function - - salt.utils.http.query(url, method='POST', header_dict=headers, data=payload) - - -def _publish_html_message(token, room, data, message='', outputter='nested', api_url=None): - ''' - Publishes the HTML-formatted message. - ''' - url = "{0}/v2/room/{1}/notification".format(api_url, room) - headers = { - 'Content-type': 'text/plain' - } - headers['Authorization'] = 'Bearer ' + token - salt.utils.http.query( - url, - 'POST', - data=message, - decode=True, - status=True, - header_dict=headers, - opts=__opts__, - ) - headers['Content-type'] = 'text/html' - message = salt.output.html_format(data, outputter, opts=__opts__) - salt.utils.http.query( - url, - 'POST', - data=message, - decode=True, - status=True, - header_dict=headers, - opts=__opts__, - ) - - -def _publish_code_message(token, room, data, message='', outputter='nested', api_url=None): - ''' - Publishes the output format as code. - ''' - url = "{0}/v2/room/{1}/notification".format(api_url, room) - headers = { - 'Content-type': 'text/plain' - } - headers['Authorization'] = 'Bearer ' + token - salt.utils.http.query( - url, - 'POST', - data=message, - decode=True, - status=True, - header_dict=headers, - opts=__opts__, - ) - message = '/code ' - message += salt.output.string_format(data, outputter, opts=__opts__) - salt.utils.http.query( - url, - 'POST', - data=message, - decode=True, - status=True, - header_dict=headers, - opts=__opts__, - ) - - -def start(token, - room='salt', - aliases=None, - valid_users=None, - valid_commands=None, - control=False, - trigger="!", - tag='salt/engines/hipchat/incoming', - api_key=None, - api_url=None, - max_rooms=None, - wait_time=None, - output_type='file', - outputter='nested'): - ''' - Listen to Hipchat messages and forward them to Salt. - - token - The HipChat API key. It requires a key for global usgae, - assigned per user, rather than room. - - room - The HipChat room name. - - aliases - Define custom aliases. - - valid_users - Restrict access only to certain users. - - valid_commands - Restrict the execution to a limited set of commands. - - control - Send commands to the master. - - trigger: ``!`` - Special character that triggers the execution of salt commands. - - tag: ``salt/engines/hipchat/incoming`` - The event tag on the Salt bus. - - api_url: ``https://api.hipchat.com`` - The URL to the HipChat API. - - .. versionadded:: 2017.7.0 - - max_rooms: ``1000`` - Maximum number of rooms allowed to fetch. If set to 0, - it is able to retrieve the entire list of rooms. - - wait_time: ``5`` - Maximum wait time, in seconds. - - output_type: ``file`` - The type of the output. Choose bewteen: - - - ``file``: save the output into a temporary file and upload - - ``html``: send the output as HTML - - ``code``: send the output as code - - This can be overridden when executing a command, using the ``--out-type`` argument. - - .. versionadded:: 2017.7.0 - - outputter: ``nested`` - The format to display the data, using the outputters available on the CLI. - This argument can also be overridden when executing a command, using the ``--out`` option. - - .. versionadded:: 2017.7.0 - - HipChat Example: - - .. code-block:: text - - ! test.ping - ! test.ping target=minion1 - ! test.ping --out=nested - ! test.ping --out-type=code --out=table - ''' - target_room = None - - if __opts__.get('__role') == 'master': - fire_master = salt.utils.event.get_master_event( - __opts__, - __opts__['sock_dir']).fire_event - else: - fire_master = None - - def fire(tag, msg): - ''' - fire event to salt bus - ''' - - if fire_master: - fire_master(msg, tag) - else: - __salt__['event.send'](tag, msg) - - def _eval_bot_mentions(all_messages, trigger): - ''' yield partner message ''' - for message in all_messages: - message_text = message['message'] - if message_text.startswith(trigger): - fire(tag, message) - text = message_text.replace(trigger, '').strip() - yield message['from']['mention_name'], text - - token = token or api_key - if not token: - raise UserWarning("Hipchat token not found") - - runner_functions = sorted(salt.runner.Runner(__opts__).functions) - - if not api_url: - api_url = _DEFAULT_API_URL - hipc = hypchat.HypChat(token, endpoint=api_url) - if not hipc: - raise UserWarning("Unable to connect to hipchat") - - log.debug('Connected to Hipchat') - rooms_kwargs = {} - if max_rooms is None: - max_rooms = _DEFAULT_MAX_ROOMS - rooms_kwargs['max_results'] = max_rooms - elif max_rooms > 0: - rooms_kwargs['max_results'] = max_rooms - # if max_rooms is 0 => retrieve all (rooms_kwargs is empty dict) - all_rooms = hipc.rooms(**rooms_kwargs)['items'] - for a_room in all_rooms: - if a_room['name'] == room: - target_room = a_room - if not target_room: - log.debug("Unable to connect to room %s", room) - # wait for a bit as to not burn through api calls - time.sleep(30) - raise UserWarning("Unable to connect to room {0}".format(room)) - - after_message_id = target_room.latest(maxResults=1)['items'][0]['id'] - - while True: - try: - new_messages = target_room.latest( - not_before=after_message_id)['items'] - except hypchat.requests.HttpServiceUnavailable: - time.sleep(15) - continue - - after_message_id = new_messages[-1]['id'] - for partner, text in _eval_bot_mentions(new_messages[1:], trigger): - # bot summoned by partner - - if not control: - log.debug("Engine not configured for control") - return - - # Ensure the user is allowed to run commands - if valid_users: - if partner not in valid_users: - target_room.message('{0} not authorized to run Salt commands'.format(partner)) - return - - args = [] - kwargs = {} - - cmdline = salt.utils.args.shlex_split(text) - cmd = cmdline[0] - - # Evaluate aliases - if aliases and isinstance(aliases, dict) and cmd in aliases.keys(): - cmdline = aliases[cmd].get('cmd') - cmdline = salt.utils.args.shlex_split(cmdline) - cmd = cmdline[0] - - # Parse args and kwargs - if len(cmdline) > 1: - for item in cmdline[1:]: - if '=' in item: - (key, value) = item.split('=', 1) - kwargs[key] = value - else: - args.append(item) - - # Check for target. Otherwise assume * - if 'target' not in kwargs: - target = '*' - else: - target = kwargs['target'] - del kwargs['target'] - - # Check for tgt_type. Otherwise assume glob - if 'tgt_type' not in kwargs: - tgt_type = 'glob' - else: - tgt_type = kwargs['tgt_type'] - del kwargs['tgt_type'] - - # Check for outputter. Otherwise assume nested - if '--out' in kwargs: - outputter = kwargs['--out'] - del kwargs['--out'] - - # Check for outputter. Otherwise assume nested - if '--out-type' in kwargs: - output_type = kwargs['--out-type'] - del kwargs['--out-type'] - - # Ensure the command is allowed - if valid_commands: - if cmd not in valid_commands: - target_room.message('Using {0} is not allowed.'.format(cmd)) - return - - ret = {} - if cmd in runner_functions: - runner = salt.runner.RunnerClient(__opts__) - ret = runner.cmd(cmd, arg=args, kwarg=kwargs) - - # Default to trying to run as a client module. - else: - local = salt.client.LocalClient() - ret = local.cmd('{0}'.format(target), cmd, args, kwargs, tgt_type='{0}'.format(tgt_type)) - - nice_args = (' ' + ' '.join(args)) if args else '' - nice_kwargs = (' ' + ' '.join('{0}={1}'.format(key, value) for (key, value) in six.iteritems(kwargs))) \ - if kwargs else '' - message_string = '@{0} Results for: {1}{2}{3} on {4}'.format(partner, - cmd, - nice_args, - nice_kwargs, - target) - if output_type == 'html': - _publish_html_message(token, room, ret, message=message_string, outputter=outputter, api_url=api_url) - elif output_type == 'code': - _publish_code_message(token, room, ret, message=message_string, outputter=outputter, api_url=api_url) - else: - tmp_path_fn = salt.utils.files.mkstemp() - with salt.utils.files.fopen(tmp_path_fn, 'w+') as fp_: - salt.utils.json.dump(ret, fp_, sort_keys=True, indent=4) - _publish_file(token, room, tmp_path_fn, message=message_string, api_url=api_url) - salt.utils.files.safe_rm(tmp_path_fn) - time.sleep(wait_time or _DEFAULT_SLEEP) diff --git a/salt/grains/minion_process.py b/salt/grains/minion_process.py index 5ad95d5d8b55..b1120de617f1 100644 --- a/salt/grains/minion_process.py +++ b/salt/grains/minion_process.py @@ -3,75 +3,57 @@ Set grains describing the minion process. ''' +# Import Python Libs from __future__ import absolute_import, print_function, unicode_literals - import os # Import salt libs +import salt.utils.user import salt.utils.platform -try: - import pwd -except ImportError: - import getpass - pwd = None - -try: - import grp -except ImportError: - grp = None - def _uid(): ''' Grain for the minion User ID ''' - if salt.utils.platform.is_windows(): - return None - return os.getuid() + return salt.utils.user.get_uid() def _username(): ''' Grain for the minion username ''' - if pwd: - username = pwd.getpwuid(os.getuid()).pw_name - else: - username = getpass.getuser() - - return username + return salt.utils.user.get_user() def _gid(): ''' Grain for the minion Group ID ''' - if salt.utils.platform.is_windows(): - return None - return os.getgid() + return salt.utils.user.get_gid() def _groupname(): ''' Grain for the minion groupname ''' - if grp: - try: - groupname = grp.getgrgid(os.getgid()).gr_name - except KeyError: - groupname = '' - else: - groupname = '' - - return groupname + try: + return salt.utils.user.get_default_group(_username()) or '' + except KeyError: + return '' def _pid(): + ''' + Return the current process pid + ''' return os.getpid() def grains(): + ''' + Return the grains dictionary + ''' ret = { 'username': _username(), 'groupname': _groupname(), diff --git a/salt/loader.py b/salt/loader.py index 74d0e07d9209..e50b14fec1f2 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -957,7 +957,7 @@ def sdb(opts, functions=None, whitelist=None, utils=None): '__sdb__': functions, '__opts__': opts, '__utils__': utils, - '__salt__': minion_mods(opts, utils), + '__salt__': minion_mods(opts, utils=utils), }, whitelist=whitelist, ) diff --git a/salt/metaproxy/proxy.py b/salt/metaproxy/proxy.py index df3fdbec1364..5e2cf3a35ca8 100644 --- a/salt/metaproxy/proxy.py +++ b/salt/metaproxy/proxy.py @@ -726,7 +726,9 @@ def handle_decoded_payload(self, data): instance = None with default_signals(signal.SIGINT, signal.SIGTERM): process = SignalHandlingProcess( - target=self._target, args=(instance, self.opts, data, self.connected) + target=self._target, + name='ProcessPayload', + args=(instance, self.opts, data, self.connected) ) else: process = threading.Thread( diff --git a/salt/minion.py b/salt/minion.py index 8666c2fe4160..123570dba132 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -457,7 +457,7 @@ def gen_modules(self, initial_load=False): # self.matcher = Matcher(self.opts, self.functions) self.matchers = salt.loader.matchers(self.opts) self.functions['sys.reload_modules'] = self.gen_modules - self.executors = salt.loader.executors(self.opts, self.functions) + self.executors = salt.loader.executors(self.opts, self.functions, proxy=self.proxy) @staticmethod def process_schedule(minion, loop_interval): @@ -1525,7 +1525,9 @@ def _handle_decoded_payload(self, data): instance = None with default_signals(signal.SIGINT, signal.SIGTERM): process = SignalHandlingProcess( - target=self._target, args=(instance, self.opts, data, self.connected) + target=self._target, + name='ProcessPayload', + args=(instance, self.opts, data, self.connected) ) else: process = threading.Thread( diff --git a/salt/modules/cmdmod.py b/salt/modules/cmdmod.py index 723eddc67b04..e0daa5d48018 100644 --- a/salt/modules/cmdmod.py +++ b/salt/modules/cmdmod.py @@ -982,8 +982,8 @@ def run(cmd, .. warning:: For versions 2018.3.3 and above on macosx while using runas, - to pass special characters to the command you need to escape - the characters on the shell. + on linux while using run, to pass special characters to the + command you need to escape the characters on the shell. Example: diff --git a/salt/modules/cp.py b/salt/modules/cp.py index e0fc3587a95e..e330948a70d2 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -423,6 +423,8 @@ def get_url(path, dest='', saltenv='base', makedirs=False, source_hash=None): log.error('Unable to fetch file %s from saltenv %s.', salt.utils.url.redact_http_basic_auth(path), saltenv) + if result: + return salt.utils.stringutils.to_unicode(result) return result @@ -443,7 +445,7 @@ def get_file_str(path, saltenv='base'): if isinstance(fn_, six.string_types): try: with salt.utils.files.fopen(fn_, 'r') as fp_: - return fp_.read() + return salt.utils.stringutils.to_unicode(fp_.read()) except IOError: return False return fn_ diff --git a/salt/modules/file.py b/salt/modules/file.py index d0847c669b76..49ca570e02df 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -5336,11 +5336,11 @@ def manage_file(name, # Write the static contents to a temporary file tmp = salt.utils.files.mkstemp(prefix=salt.utils.files.TEMPFILE_PREFIX, text=True) - if salt.utils.platform.is_windows(): - contents = os.linesep.join( - _splitlines_preserving_trailing_newline(contents)) with salt.utils.files.fopen(tmp, 'wb') as tmp_: if encoding: + if salt.utils.platform.is_windows(): + contents = os.linesep.join( + _splitlines_preserving_trailing_newline(contents)) log.debug('File will be encoded with %s', encoding) tmp_.write(contents.encode(encoding=encoding, errors=encoding_errors)) else: diff --git a/salt/modules/hipchat.py b/salt/modules/hipchat.py deleted file mode 100644 index db7e5891279e..000000000000 --- a/salt/modules/hipchat.py +++ /dev/null @@ -1,356 +0,0 @@ -# -*- coding: utf-8 -*- -''' -Module for sending messages to hipchat. - -.. versionadded:: 2015.5.0 - -:configuration: This module can be used by either passing an api key and version - directly or by specifying both in a configuration profile in the salt - master/minion config. - - It is possible to use a different API than http://api.hipchat.com, - by specifying the API URL in config as api_url, or by passing the value directly. - - For example: - - .. code-block:: yaml - - hipchat: - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15 - api_version: v1 - - Custom API Example: - - .. code-block:: yaml - - hipchat: - api_url: http://api.hipchat.myteam.com - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15 - api_version: v2 -''' -# Import Python Libs -from __future__ import absolute_import, print_function, unicode_literals -import logging - -# Import Salt libs -import salt.utils.http -import salt.utils.json - -# Import 3rd-party Libs -# pylint: disable=import-error,no-name-in-module,redefined-builtin -from salt.ext.six.moves.urllib.parse import urljoin as _urljoin -from salt.ext.six.moves.urllib.parse import urlencode as _urlencode -from salt.ext.six.moves import range -import salt.ext.six.moves.http_client - -# pylint: enable=import-error,no-name-in-module,redefined-builtin - -log = logging.getLogger(__name__) - -__virtualname__ = 'hipchat' - - -def __virtual__(): - ''' - Return virtual name of the module. - - :return: The virtual name of the module. - ''' - return __virtualname__ - - -def _query(function, - api_url=None, - api_key=None, - api_version=None, - room_id=None, - method='GET', - data=None): - ''' - HipChat object method function to construct and execute on the API URL. - - :param api_url: The HipChat API URL. - :param api_key: The HipChat api key. - :param function: The HipChat api function to perform. - :param api_version: The HipChat api version (v1 or v2). - :param method: The HTTP method, e.g. GET or POST. - :param data: The data to be sent for POST method. - :return: The json response from the API call or False. - ''' - headers = {} - query_params = {} - - if not api_url: - try: - options = __salt__['config.option']('hipchat') - api_url = options.get('api_url') - except (NameError, KeyError, AttributeError): - pass # not mandatory, thus won't fail if not found - - if not api_key or not api_version: - try: - options = __salt__['config.option']('hipchat') - if not api_key: - api_key = options.get('api_key') - if not api_version: - api_version = options.get('api_version') - except (NameError, KeyError, AttributeError): - log.error("No HipChat api key or version found.") - return False - - if room_id: - room_id = 'room/{0}/notification'.format(room_id) - else: - room_id = 'room/0/notification' - - hipchat_functions = { - 'v1': { - 'rooms': { - 'request': 'rooms/list', - 'response': 'rooms', - }, - 'users': { - 'request': 'users/list', - 'response': 'users', - }, - 'message': { - 'request': 'rooms/message', - 'response': 'status', - }, - }, - 'v2': { - 'rooms': { - 'request': 'room', - 'response': 'items', - }, - 'users': { - 'request': 'user', - 'response': 'items', - }, - 'message': { - 'request': room_id, - 'response': None, - }, - }, - } - - use_api_url = 'https://api.hipchat.com' # default API URL - if api_url: - use_api_url = api_url - base_url = _urljoin(use_api_url, api_version + '/') - path = hipchat_functions.get(api_version).get(function).get('request') - url = _urljoin(base_url, path, False) - - if api_version == 'v1': - query_params['format'] = 'json' - query_params['auth_token'] = api_key - - if method == 'POST': - headers['Content-Type'] = 'application/x-www-form-urlencoded' - - if data: - if data.get('notify', None): - data['notify'] = 1 - data = _urlencode(data) - elif api_version == 'v2': - headers['Authorization'] = 'Bearer {0}'.format(api_key) - if data: - data = salt.utils.json.dumps(data) - - if method == 'POST': - headers['Content-Type'] = 'application/json' - else: - log.error('Unsupported HipChat API version') - return False - - result = salt.utils.http.query( - url, - method, - params=query_params, - data=data, - decode=True, - status=True, - header_dict=headers, - opts=__opts__, - ) - - if result.get('status', None) == salt.ext.six.moves.http_client.OK: - response = hipchat_functions.get(api_version).get(function).get('response') - return result.get('dict', {}).get(response, None) - elif result.get('status', None) == salt.ext.six.moves.http_client.NO_CONTENT and \ - api_version == 'v2': - return True - else: - log.debug(url) - log.debug(query_params) - log.debug(data) - log.debug(result) - if result.get('error'): - log.error(result) - return False - - -def list_rooms(api_url=None, - api_key=None, - api_version=None): - ''' - List all HipChat rooms. - - :param api_url: The HipChat API URL, if not specified in the configuration. - :param api_key: The HipChat admin api key. - :param api_version: The HipChat api version, if not specified in the configuration. - :return: The room list. - - CLI Example: - - .. code-block:: bash - - salt '*' hipchat.list_rooms - - salt '*' hipchat.list_rooms api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1 - ''' - foo = _query(function='rooms', - api_url=api_url, - api_key=api_key, - api_version=api_version) - log.debug('foo %s', foo) - return foo - - -def list_users(api_url=None, - api_key=None, - api_version=None): - ''' - List all HipChat users. - - :param api_url: The HipChat API URL, if not specified in the configuration. - :param api_key: The HipChat admin api key. - :param api_version: The HipChat api version, if not specified in the configuration. - :return: The user list. - - CLI Example: - - .. code-block:: bash - - salt '*' hipchat.list_users - - salt '*' hipchat.list_users api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1 - ''' - return _query(function='users', - api_url=api_url, - api_key=api_key, - api_version=api_version) - - -def find_room(name, - api_url=None, - api_key=None, - api_version=None): - ''' - Find a room by name and return it. - - :param name: The room name. - :param api_url: The HipChat API URL, if not specified in the configuration. - :param api_key: The HipChat admin api key. - :param api_version: The HipChat api version, if not specified in the configuration. - :return: The room object. - - CLI Example: - - .. code-block:: bash - - salt '*' hipchat.find_room name="Development Room" - - salt '*' hipchat.find_room name="Development Room" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1 - ''' - rooms = list_rooms(api_url=api_url, - api_key=api_key, - api_version=api_version) - if rooms: - for x in range(0, len(rooms)): - if rooms[x]['name'] == name: - return rooms[x] - return False - - -def find_user(name, - api_url=None, - api_key=None, - api_version=None): - ''' - Find a user by name and return it. - - :param name: The user name. - :param api_url: The HipChat API URL, if not specified in the configuration. - :param api_key: The HipChat admin api key. - :param api_version: The HipChat api version, if not specified in the configuration. - :return: The user object. - - CLI Example: - - .. code-block:: bash - - salt '*' hipchat.find_user name="Thomas Hatch" - - salt '*' hipchat.find_user name="Thomas Hatch" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1 - ''' - users = list_users(api_url=api_url, - api_key=api_key, - api_version=api_version) - if users: - for x in range(0, len(users)): - if users[x]['name'] == name: - return users[x] - return False - - -def send_message(room_id, - message, - from_name, - api_url=None, - api_key=None, - api_version=None, - color='yellow', - notify=False): - ''' - Send a message to a HipChat room. - - :param room_id: The room id or room name, either will work. - :param message: The message to send to the HipChat room. - :param from_name: Specify who the message is from. - :param api_url: The HipChat api URL, if not specified in the configuration. - :param api_key: The HipChat api key, if not specified in the configuration. - :param api_version: The HipChat api version, if not specified in the configuration. - :param color: The color for the message, default: yellow. - :param notify: Whether to notify the room, default: False. - :return: Boolean if message was sent successfully. - - CLI Example: - - .. code-block:: bash - - salt '*' hipchat.send_message room_id="Development Room" message="Build is done" from_name="Build Server" - - salt '*' hipchat.send_message room_id="Development Room" message="Build failed" from_name="Build Server" color="red" notify=True - ''' - - parameters = dict() - parameters['room_id'] = room_id - parameters['from'] = from_name[:15] - parameters['message'] = message[:10000] - parameters['message_format'] = 'text' - parameters['color'] = color - parameters['notify'] = notify - - result = _query(function='message', - api_url=api_url, - api_key=api_key, - api_version=api_version, - room_id=room_id, - method='POST', - data=parameters) - - if result: - return True - else: - return False diff --git a/salt/modules/mdadm_raid.py b/salt/modules/mdadm_raid.py index 829f4cdd245e..93dd0a1e3336 100644 --- a/salt/modules/mdadm_raid.py +++ b/salt/modules/mdadm_raid.py @@ -360,17 +360,25 @@ def assemble(name, return __salt__['cmd.run'](cmd, python_shell=False) -def examine(device): +def examine(device, quiet=False): ''' Show detail for a specified RAID component device + device + Device to examine, that is part of the RAID + + quiet + If the device is not part of the RAID, do not show any error + CLI Example: .. code-block:: bash salt '*' raid.examine '/dev/sda1' ''' - res = __salt__['cmd.run_stdout']('mdadm -Y -E {0}'.format(device), output_loglevel='trace', python_shell=False) + res = __salt__['cmd.run_stdout']('mdadm -Y -E {0}'.format(device), + python_shell=False, + ignore_retcode=quiet) ret = {} for line in res.splitlines(): diff --git a/salt/modules/pip.py b/salt/modules/pip.py index eac40c719cfa..a456b3b9c612 100644 --- a/salt/modules/pip.py +++ b/salt/modules/pip.py @@ -433,6 +433,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 no_cache_dir=False, cache_dir=None, no_binary=None, + disable_version_check=False, **kwargs): ''' Install packages with pip @@ -604,6 +605,11 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 no_cache_dir Disable the cache. + disable_version_check + Pip may periodically check PyPI to determine whether a new version of + pip is available to download. Passing True for this option disables + that check. + CLI Example: .. code-block:: bash @@ -756,6 +762,9 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 ) cmd.extend(['--mirrors', mirror]) + if disable_version_check: + cmd.extend(['--disable-pip-version-check']) + if build: cmd.extend(['--build', build]) diff --git a/salt/modules/saltutil.py b/salt/modules/saltutil.py index b3351e70d374..f1f77cf1f399 100644 --- a/salt/modules/saltutil.py +++ b/salt/modules/saltutil.py @@ -918,6 +918,45 @@ def sync_pillar(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blackl return ret +def sync_executors(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None): + ''' + .. versionadded:: Neon + + Sync executors from ``salt://_executors`` to the minion + + saltenv + The fileserver environment from which to sync. To sync from more than + one environment, pass a comma-separated list. + + If not passed, then all environments configured in the :ref:`top files + ` will be checked for log handlers to sync. If no top files + are found, then the ``base`` environment will be synced. + + refresh : True + If ``True``, refresh the available execution modules on the minion. + This refresh will be performed even if no new log handlers are synced. + Set to ``False`` to prevent this refresh. + + extmod_whitelist : None + comma-seperated list of modules to sync + + extmod_blacklist : None + comma-seperated list of modules to blacklist based on type + + CLI Examples: + + .. code-block:: bash + + salt '*' saltutil.sync_executors + salt '*' saltutil.sync_executors saltenv=dev + salt '*' saltutil.sync_executors saltenv=base,dev + ''' + ret = _sync('executors', saltenv, extmod_whitelist, extmod_blacklist) + if refresh: + refresh_modules() + return ret + + def sync_all(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None): ''' .. versionchanged:: 2015.8.11,2016.3.2 @@ -978,6 +1017,7 @@ def sync_all(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist ret['output'] = sync_output(saltenv, False, extmod_whitelist, extmod_blacklist) ret['utils'] = sync_utils(saltenv, False, extmod_whitelist, extmod_blacklist) ret['log_handlers'] = sync_log_handlers(saltenv, False, extmod_whitelist, extmod_blacklist) + ret['executors'] = sync_executors(saltenv, False, extmod_whitelist, extmod_blacklist) ret['proxymodules'] = sync_proxymodules(saltenv, False, extmod_whitelist, extmod_blacklist) ret['engines'] = sync_engines(saltenv, False, extmod_whitelist, extmod_blacklist) ret['thorium'] = sync_thorium(saltenv, False, extmod_whitelist, extmod_blacklist) diff --git a/salt/modules/upstart_service.py b/salt/modules/upstart_service.py index eb6362b2d9d3..751507c4530f 100644 --- a/salt/modules/upstart_service.py +++ b/salt/modules/upstart_service.py @@ -50,7 +50,6 @@ import glob import os import re -import itertools import fnmatch # Import salt libs @@ -58,6 +57,7 @@ import salt.utils.files import salt.utils.path import salt.utils.systemd +from salt.ext.six.moves import filter # pylint: disable=import-error,redefined-builtin __func_alias__ = { 'reload_': 'reload' @@ -190,7 +190,7 @@ def _upstart_is_disabled(name): in /etc/init/[name].conf. ''' files = ['/etc/init/{0}.conf'.format(name), '/etc/init/{0}.override'.format(name)] - for file_name in itertools.ifilter(os.path.isfile, files): + for file_name in filter(os.path.isfile, files): with salt.utils.files.fopen(file_name) as fp_: if re.search(r'^\s*manual', salt.utils.stringutils.to_unicode(fp_.read()), @@ -516,7 +516,7 @@ def _upstart_enable(name): return _upstart_is_enabled(name) override = '/etc/init/{0}.override'.format(name) files = ['/etc/init/{0}.conf'.format(name), override] - for file_name in itertools.ifilter(os.path.isfile, files): + for file_name in filter(os.path.isfile, files): with salt.utils.files.fopen(file_name, 'r+') as fp_: new_text = re.sub(r'^\s*manual\n?', '', diff --git a/salt/modules/virt.py b/salt/modules/virt.py index 25bc5b43a85e..84b90e9b1f4a 100644 --- a/salt/modules/virt.py +++ b/salt/modules/virt.py @@ -3309,7 +3309,7 @@ def get_hypervisor(): # To add a new 'foo' hypervisor, add the _is_foo_hyper function, # add 'foo' to the list below and add it to the docstring with a .. versionadded:: hypervisors = ['kvm', 'xen'] - result = [hyper for hyper in hypervisors if getattr(sys.modules[__name__], '_is_{}_hyper').format(hyper)()] + result = [hyper for hyper in hypervisors if getattr(sys.modules[__name__], '_is_{}_hyper'.format(hyper))()] return result[0] if result else None diff --git a/salt/modules/zpool.py b/salt/modules/zpool.py index 64de2194f92c..bfd879d352d9 100644 --- a/salt/modules/zpool.py +++ b/salt/modules/zpool.py @@ -9,8 +9,8 @@ :platform: illumos,freebsd,linux .. versionchanged:: 2018.3.1 - Big refactor to remove duplicate code, better type converions and improved - consistancy in output. + Big refactor to remove duplicate code, better type conversions and improved + consistency in output. ''' from __future__ import absolute_import, print_function, unicode_literals @@ -143,7 +143,7 @@ def status(zpool=None): ## parse status output # NOTE: output is 'key: value' except for the 'config' key. - # mulitple pools will repeat the output, so if switch pools if + # multiple pools will repeat the output, so if switch pools if # we see 'pool:' current_pool = None current_prop = None @@ -195,7 +195,7 @@ def status(zpool=None): # NOTE: data is indented by 1 tab, then multiples of 2 spaces # to differential root vdev, vdev, and dev # - # we just strip the intial tab (can't use .strip() here) + # we just strip the initial tab (can't use .strip() here) if line[0] == "\t": line = line[1:] @@ -372,7 +372,7 @@ def list_(properties='size,alloc,free,cap,frag,health', zpool=None, parsable=Tru .. note:: - Multiple storage pool can be provded as a space separated list + Multiple storage pool can be provided as a space separated list CLI Example: diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index 07f13b4ee98f..e36817f81097 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -226,7 +226,7 @@ Setting a :conf_minion:`pillarenv` in the minion config file will make that minion tell the master to ignore any pillar data from environments which don't match that pillarenv. A pillarenv can also be specified for a given minion or -set of minions when :mod:`running states `, by using he +set of minions when :mod:`running states `, by using the ``pillarenv`` argument. The CLI pillarenv will override one set in the minion config file. So, assuming that a pillarenv of ``base`` was set for a minion, it would not get any of the pillar variables configured in the ``qux`` remote, diff --git a/salt/returners/hipchat_return.py b/salt/returners/hipchat_return.py deleted file mode 100644 index a777a7322803..000000000000 --- a/salt/returners/hipchat_return.py +++ /dev/null @@ -1,400 +0,0 @@ -# -*- coding: utf-8 -*- -''' -Return salt data via hipchat. - -.. versionadded:: 2015.5.0 - -The following fields can be set in the minion conf file:: - - hipchat.room_id (required) - hipchat.api_key (required) - hipchat.api_version (required) - hipchat.api_url (optional) - hipchat.from_name (required) - hipchat.color (optional) - hipchat.notify (optional) - hipchat.profile (optional) - hipchat.url (optional) - -.. note:: - - When using Hipchat's API v2, ``api_key`` needs to be assigned to the room with the - "Label" set to what you would have been set in the hipchat.from_name field. The v2 - API disregards the ``from_name`` in the data sent for the room notification and uses - the Label assigned through the Hipchat control panel. - -Alternative configuration values can be used by prefacing the configuration. -Any values not found in the alternative configuration will be pulled from -the default location:: - - hipchat.room_id - hipchat.api_key - hipchat.api_version - hipchat.api_url - hipchat.from_name - -Hipchat settings may also be configured as: - -.. code-block:: yaml - - hipchat: - room_id: RoomName - api_url: https://hipchat.myteam.con - api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - api_version: v1 - from_name: user@email.com - - alternative.hipchat: - room_id: RoomName - api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - api_version: v1 - from_name: user@email.com - - hipchat_profile: - hipchat.api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - hipchat.api_version: v1 - hipchat.from_name: user@email.com - - hipchat: - profile: hipchat_profile - room_id: RoomName - - alternative.hipchat: - profile: hipchat_profile - room_id: RoomName - - hipchat: - room_id: RoomName - api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - api_version: v1 - api_url: api.hipchat.com - from_name: user@email.com - -To use the HipChat returner, append '--return hipchat' to the salt command. - -.. code-block:: bash - - salt '*' test.ping --return hipchat - -To use the alternative configuration, append '--return_config alternative' to the salt command. - -.. versionadded:: 2015.5.0 - -.. code-block:: bash - - salt '*' test.ping --return hipchat --return_config alternative - -To override individual configuration items, append --return_kwargs '{"key:": "value"}' to the salt command. - -.. versionadded:: 2016.3.0 - -.. code-block:: bash - - salt '*' test.ping --return hipchat --return_kwargs '{"room_id": "another-room"}' - -''' -from __future__ import absolute_import, print_function, unicode_literals - -# Import Python libs -import pprint -import logging - -# pylint: disable=import-error,no-name-in-module -from salt.ext import six -from salt.ext.six.moves.urllib.parse import urljoin as _urljoin -from salt.ext.six.moves.urllib.parse import urlencode as _urlencode -import salt.ext.six.moves.http_client -# pylint: enable=import-error - -# Import Salt Libs -import salt.returners -import salt.utils.json - - -log = logging.getLogger(__name__) -__virtualname__ = 'hipchat' - - -def _get_options(ret=None): - ''' - Get the hipchat options from salt. - ''' - - defaults = {'color': 'yellow', - 'notify': False, - 'api_url': 'api.hipchat.com'} - - attrs = {'hipchat_profile': 'profile', - 'room_id': 'room_id', - 'from_name': 'from_name', - 'api_key': 'api_key', - 'api_version': 'api_version', - 'color': 'color', - 'notify': 'notify', - 'api_url': 'api_url', - } - - profile_attr = 'hipchat_profile' - - profile_attrs = {'from_jid': 'from_jid', - 'api_key': 'api_key', - 'api_version': 'api_key', - 'api_url': 'api_url', - } - - _options = salt.returners.get_returner_options(__virtualname__, - ret, - attrs, - profile_attr=profile_attr, - profile_attrs=profile_attrs, - __salt__=__salt__, - __opts__=__opts__, - defaults=defaults) - return _options - - -def __virtual__(): - ''' - Return virtual name of the module. - - :return: The virtual name of the module. - ''' - return __virtualname__ - - -def _query(function, - api_key=None, - api_version=None, - room_id=None, - api_url=None, - method='GET', - data=None): - ''' - HipChat object method function to construct and execute on the API URL. - - :param api_url: The HipChat API URL. - :param api_key: The HipChat api key. - :param function: The HipChat api function to perform. - :param api_version: The HipChat api version (v1 or v2). - :param method: The HTTP method, e.g. GET or POST. - :param data: The data to be sent for POST method. - :return: The json response from the API call or False. - ''' - headers = {} - query_params = {} - - if room_id: - room_id = 'room/{0}/notification'.format(six.text_type(room_id)) - else: - room_id = 'room/0/notification' - - hipchat_functions = { - 'v1': { - 'rooms': { - 'request': 'rooms/list', - 'response': 'rooms', - }, - 'users': { - 'request': 'users/list', - 'response': 'users', - }, - 'message': { - 'request': 'rooms/message', - 'response': 'status', - }, - }, - 'v2': { - 'rooms': { - 'request': 'room', - 'response': 'items', - }, - 'users': { - 'request': 'user', - 'response': 'items', - }, - 'message': { - 'request': room_id, - 'response': None, - }, - }, - } - - api_url = 'https://{0}'.format(api_url) - base_url = _urljoin(api_url, api_version + '/') - path = hipchat_functions.get(api_version).get(function).get('request') - url = _urljoin(base_url, path, False) - - if api_version == 'v1': - query_params['format'] = 'json' - query_params['auth_token'] = api_key - - if method == 'POST': - headers['Content-Type'] = 'application/x-www-form-urlencoded' - - if data: - if data.get('notify'): - data['notify'] = 1 - else: - data['notify'] = 0 - data = _urlencode(data) - elif api_version == 'v2': - headers['Content-Type'] = 'application/json' - headers['Authorization'] = 'Bearer {0}'.format(api_key) - if data: - data = salt.utils.json.dumps(data) - else: - log.error('Unsupported HipChat API version') - return False - - result = salt.utils.http.query( - url, - method, - params=query_params, - data=data, - decode=True, - status=True, - header_dict=headers, - opts=__opts__, - ) - - if result.get('status', None) == salt.ext.six.moves.http_client.OK: - response = hipchat_functions.get(api_version).get(function).get('response') - return result.get('dict', {}).get(response, None) - elif result.get('status', None) == salt.ext.six.moves.http_client.NO_CONTENT: - return False - else: - log.debug(url) - log.debug(query_params) - log.debug(data) - log.debug(result) - if result.get('error'): - log.error(result) - return False - - -def _send_message(room_id, - message, - from_name, - api_key=None, - api_version=None, - api_url=None, - color=None, - notify=False): - ''' - Send a message to a HipChat room. - :param room_id: The room id or room name, either will work. - :param message: The message to send to the HipChat room. - :param from_name: Specify who the message is from. - :param api_url: The HipChat API URL, if not specified in the configuration. - :param api_key: The HipChat api key, if not specified in the configuration. - :param api_version: The HipChat api version, if not specified in the configuration. - :param color: The color for the message, default: yellow. - :param notify: Whether to notify the room, default: False. - :return: Boolean if message was sent successfully. - ''' - - parameters = dict() - parameters['room_id'] = room_id - parameters['from'] = from_name[:15] - parameters['message'] = message[:10000] - parameters['message_format'] = 'text' - parameters['color'] = color - parameters['notify'] = notify - - result = _query(function='message', - api_key=api_key, - api_version=api_version, - room_id=room_id, - api_url=api_url, - method='POST', - data=parameters) - - if result: - return True - else: - return False - - -def _verify_options(options): - ''' - Verify Hipchat options and log warnings - - Returns True if all options can be verified, - otherwise False - ''' - if not options.get('room_id'): - log.error('hipchat.room_id not defined in salt config') - return False - - if not options.get('from_name'): - log.error('hipchat.from_name not defined in salt config') - return False - - if not options.get('api_key'): - log.error('hipchat.api_key not defined in salt config') - return False - - if not options.get('api_version'): - log.error('hipchat.api_version not defined in salt config') - return False - - return True - - -def returner(ret): - ''' - Send an hipchat message with the return data from a job - ''' - - _options = _get_options(ret) - - if not _verify_options(_options): - return - - message = ('id: {0}\r\n' - 'function: {1}\r\n' - 'function args: {2}\r\n' - 'jid: {3}\r\n' - 'return: {4}\r\n').format( - ret.get('id'), - ret.get('fun'), - ret.get('fun_args'), - ret.get('jid'), - pprint.pformat(ret.get('return'))) - - if ret.get('retcode') == 0: - color = _options.get('color') - else: - color = 'red' - - hipchat = _send_message(_options.get('room_id'), # room_id - message, # message - _options.get('from_name'), # from_name - api_key=_options.get('api_key'), - api_version=_options.get('api_version'), - api_url=_options.get('api_url'), - color=color, - notify=_options.get('notify')) - - return hipchat - - -def event_return(events): - ''' - Return event data to hipchat - ''' - _options = _get_options() - - for event in events: - # TODO: - # Pre-process messages to apply individualized colors for various - # event types. - log.trace('Hipchat returner received event: %s', event) - _send_message(_options.get('room_id'), # room_id - event['data'], # message - _options.get('from_name'), # from_name - api_key=_options.get('api_key'), - api_version=_options.get('api_version'), - api_url=_options.get('api_url'), - color=_options.get('color'), - notify=_options.get('notify')) diff --git a/salt/returners/slack_webhook_return.py b/salt/returners/slack_webhook_return.py new file mode 100644 index 000000000000..aad1cdf656ab --- /dev/null +++ b/salt/returners/slack_webhook_return.py @@ -0,0 +1,338 @@ +# -*- coding: utf-8 -*- +''' +Return salt data via Slack using Incoming Webhooks + +:codeauthor: `Carlos D. Álvaro ` + +The following fields can be set in the minion conf file: + +.. code-block:: none + + slack_webhook.webhook (required, the webhook id. Just the part after: 'https://hooks.slack.com/services/') + slack_webhook.success_title (optional, short title for succeeded states. By default: '{id} | Succeeded') + slack_webhook.failure_title (optional, short title for failed states. By default: '{id} | Failed') + slack_webhook.author_icon (optional, a URL that with a small 16x16px image. Must be of type: GIF, JPEG, PNG, and BMP) + slack_webhook.show_tasks (optional, show identifiers for changed and failed tasks. By default: False) + +Alternative configuration values can be used by prefacing the configuration. +Any values not found in the alternative configuration will be pulled from +the default location: + +.. code-block:: none + + slack_webhook.webhook + slack_webhook.success_title + slack_webhook.failure_title + slack_webhook.author_icon + slack_webhook.show_tasks + +Slack settings may also be configured as: + +.. code-block:: none + + slack_webhook: + webhook: T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX + success_title: [{id}] | Success + failure_title: [{id}] | Failure + author_icon: https://platform.slack-edge.com/img/default_application_icon.png + show_tasks: true + + alternative.slack_webhook: + webhook: T00000000/C00000000/YYYYYYYYYYYYYYYYYYYYYYYY + show_tasks: false + +To use the Slack returner, append '--return slack_webhook' to the salt command. + +.. code-block:: bash + + salt '*' test.ping --return slack_webhook + +To use the alternative configuration, append '--return_config alternative' to the salt command. + +.. code-block:: bash + + salt '*' test.ping --return slack_webhook --return_config alternative + +''' +from __future__ import absolute_import, print_function, unicode_literals + +# Import Python libs +import logging +import json + +# pylint: disable=import-error,no-name-in-module,redefined-builtin +import salt.ext.six.moves.http_client +from salt.ext.six.moves.urllib.parse import urlencode as _urlencode +from salt.ext import six +from salt.ext.six.moves import map +from salt.ext.six.moves import range +# pylint: enable=import-error,no-name-in-module,redefined-builtin + +# Import Salt Libs +import salt.returners +import salt.utils.http +import salt.utils.yaml + +log = logging.getLogger(__name__) + +__virtualname__ = 'slack_webhook' + + +def _get_options(ret=None): + ''' + Get the slack_webhook options from salt. + :param ret: Salt return dictionary + :return: A dictionary with options + ''' + + defaults = { + 'success_title': '{id} | Succeeded', + 'failure_title': '{id} | Failed', + 'author_icon': '', + 'show_tasks': False + } + + attrs = { + 'webhook': 'webhook', + 'success_title': 'success_title', + 'failure_title': 'failure_title', + 'author_icon': 'author_icon', + 'show_tasks': 'show_tasks' + } + + _options = salt.returners.get_returner_options(__virtualname__, + ret, + attrs, + __salt__=__salt__, + __opts__=__opts__, + defaults=defaults) + return _options + + +def __virtual__(): + ''' + Return virtual name of the module. + + :return: The virtual name of the module. + ''' + return __virtualname__ + + +def _sprinkle(config_str): + ''' + Sprinkle with grains of salt, that is + convert 'test {id} test {host} ' types of strings + :param config_str: The string to be sprinkled + :return: The string sprinkled + ''' + parts = [x for sub in config_str.split('{') for x in sub.split('}')] + for i in range(1, len(parts), 2): + parts[i] = six.text_type(__grains__.get(parts[i], '')) + return ''.join(parts) + + +def _format_task(task): + ''' + Return a dictionary with the task ready for slack fileds + :param task: The name of the task + + :return: A dictionary ready to be inserted in Slack fields array + ''' + return {'value': task, 'short': False} + + +def _generate_payload(author_icon, title, report): + ''' + Prepare the payload for Slack + :param author_icon: The url for the thumbnail to be displayed + :param title: The title of the message + :param report: A dictionary with the report of the Salt function + :return: The payload ready for Slack + ''' + + title = _sprinkle(title) + + unchanged = { + 'color': 'good', + 'title': 'Unchanged: {unchanged}'.format(unchanged=report['unchanged'].get('counter', None)) + } + + changed = { + 'color': 'warning', + 'title': 'Changed: {changed}'.format(changed=report['changed'].get('counter', None)) + } + + if report['changed'].get('tasks'): + changed['fields'] = list( + map(_format_task, report['changed'].get('tasks'))) + + failed = { + 'color': 'danger', + 'title': 'Failed: {failed}'.format(failed=report['failed'].get('counter', None)) + } + + if report['failed'].get('tasks'): + failed['fields'] = list( + map(_format_task, report['failed'].get('tasks'))) + + text = 'Function: {function}\n'.format(function=report.get('function')) + if report.get('arguments'): + text += 'Function Args: {arguments}\n'.format( + arguments=str(list(map(str, report.get('arguments'))))) + + text += 'JID: {jid}\n'.format(jid=report.get('jid')) + text += 'Total: {total}\n'.format(total=report.get('total')) + text += 'Duration: {duration:.2f} secs'.format( + duration=float(report.get('duration'))) + + payload = { + 'attachments': [ + { + 'fallback': title, + 'color': "#272727", + 'author_name': _sprinkle('{id}'), + 'author_link': _sprinkle('{localhost}'), + 'author_icon': author_icon, + 'title': 'Success: {success}'.format(success=str(report.get('success'))), + 'text': text + }, + unchanged, + changed, + failed + ] + } + + return payload + + +def _generate_report(ret, show_tasks): + ''' + Generate a report of the Salt function + :param ret: The Salt return + :param show_tasks: Flag to show the name of the changed and failed states + :return: The report + ''' + + returns = ret.get('return') + + sorted_data = sorted( + returns.items(), + key=lambda s: s[1].get('__run_num__', 0) + ) + + total = 0 + failed = 0 + changed = 0 + duration = 0.0 + + changed_tasks = [] + failed_tasks = [] + + # gather stats + for state, data in sorted_data: + # state: module, stateid, name, function + _, stateid, _, _ = state.split('_|-') + task = '{filename}.sls | {taskname}'.format( + filename=str(data.get('__sls__')), taskname=stateid) + + if not data.get('result', True): + failed += 1 + failed_tasks.append(task) + + if data.get('changes', {}): + changed += 1 + changed_tasks.append(task) + + total += 1 + try: + duration += float(data.get('duration', 0.0)) + except ValueError: + pass + + unchanged = total - failed - changed + + log.debug('%s total: %s', __virtualname__, total) + log.debug('%s failed: %s', __virtualname__, failed) + log.debug('%s unchanged: %s', __virtualname__, unchanged) + log.debug('%s changed: %s', __virtualname__, changed) + + report = { + 'id': ret.get('id'), + 'success': True if failed == 0 else False, + 'total': total, + 'function': ret.get('fun'), + 'arguments': ret.get('fun_args', []), + 'jid': ret.get('jid'), + 'duration': duration / 1000, + 'unchanged': { + 'counter': unchanged + }, + 'changed': { + 'counter': changed, + 'tasks': changed_tasks if show_tasks else [] + }, + 'failed': { + 'counter': failed, + 'tasks': failed_tasks if show_tasks else [] + } + } + + return report + + +def _post_message(webhook, author_icon, title, report): + ''' + Send a message to a Slack room through a webhook + :param webhook: The url of the incoming webhook + :param author_icon: The thumbnail image to be displayed on the right side of the message + :param title: The title of the message + :param report: The report of the function state + :return: Boolean if message was sent successfully + ''' + + payload = _generate_payload(author_icon, title, report) + + data = _urlencode({ + 'payload': json.dumps(payload, ensure_ascii=False) + }) + + webhook_url = 'https://hooks.slack.com/services/{webhook}'.format(webhook=webhook) + query_result = salt.utils.http.query(webhook_url, 'POST', data=data) + + if query_result['body'] == 'ok' or query_result['status'] <= 201: + return True + else: + log.error('Slack incoming webhook message post result: %s', query_result) + return { + 'res': False, + 'message': query_result.get('body', query_result['status']) + } + + +def returner(ret): + ''' + Send a slack message with the data through a webhook + :param ret: The Salt return + :return: The result of the post + ''' + + _options = _get_options(ret) + + webhook = _options.get('webhook', None) + show_tasks = _options.get('show_tasks') + author_icon = _options.get('author_icon') + + if not webhook or webhook is '': + log.error('%s.webhook not defined in salt config', __virtualname__) + return + + report = _generate_report(ret, show_tasks) + + if report.get('success'): + title = _options.get('success_title') + else: + title = _options.get('failure_title') + + slack = _post_message(webhook, author_icon, title, report) + + return slack diff --git a/salt/runners/saltutil.py b/salt/runners/saltutil.py index 6f6af53dea38..f80e865f29cc 100644 --- a/salt/runners/saltutil.py +++ b/salt/runners/saltutil.py @@ -64,6 +64,7 @@ def sync_all(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ret['tops'] = sync_tops(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) ret['tokens'] = sync_eauth_tokens(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) ret['serializers'] = sync_serializers(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) + ret['executors'] = sync_executors(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) return ret @@ -607,3 +608,29 @@ def sync_serializers(saltenv='base', extmod_whitelist=None, extmod_blacklist=Non ''' return salt.utils.extmods.sync(__opts__, 'serializers', saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist)[0] + + +def sync_executors(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): + ''' + .. versionadded:: Neon + + Sync executor modules from ``salt://_executors`` to the master + + saltenv : base + The fileserver environment from which to sync. To sync from more than + one environment, pass a comma-separated list. + + extmod_whitelist : None + comma-seperated list of modules to sync + + extmod_blacklist : None + comma-seperated list of modules to blacklist based on type + + CLI Example: + + .. code-block:: bash + + salt-run saltutil.sync_executors + ''' + return salt.utils.extmods.sync(__opts__, 'executors', saltenv=saltenv, extmod_whitelist=extmod_whitelist, + extmod_blacklist=extmod_blacklist)[0] diff --git a/salt/states/disk.py b/salt/states/disk.py index 82254a391a2e..aca5f7c2d113 100644 --- a/salt/states/disk.py +++ b/salt/states/disk.py @@ -47,10 +47,11 @@ # Import salt libs from salt.ext.six import string_types +from os import path __monitor__ = [ - 'status', - ] + 'status', +] def _validate_int(name, value, limits=(), strip='%'): @@ -74,12 +75,88 @@ def _validate_int(name, value, limits=(), strip='%'): return value, comment -def status(name, maximum=None, minimum=None, absolute=False): +def _status_mount(name, ret, minimum, maximum, absolute, free, data): + # Get used space + if absolute: + used = int(data[name]['used']) + available = int(data[name]['available']) + else: + # POSIX-compliant df output reports percent used as 'capacity' + used = int(data[name]['capacity'].strip('%')) + available = 100 - used + + # Collect return information + ret['data'] = data[name] + return _check_min_max(absolute, free, available, used, maximum, minimum, ret) + + +def _status_path(directory, ret, minimum, maximum, absolute, free): + if path.isdir(directory) is False: + ret['result'] = False + ret['comment'] += ('Directory {0} does not exist or is not a directory'.format(directory)) + return ret + + data = __salt__['status.diskusage'](directory) + + if absolute: + used = int(data[directory]['total']) - int(data[directory]['available']) + available = int(data[directory]['available']) + else: + if int(data[directory]['total']) == 0: + used = 0 + available = 0 + else: + used = round(float(int(data[directory]['total']) - int(data[directory]['available'])) / + int(data[directory]['total']) * 100, 1) + available = round(float(data[directory]['available']) / int(data[directory]['total']) * 100, 1) + + ret['data'] = data + return _check_min_max(absolute, free, available, used, maximum, minimum, ret) + + +def _check_min_max(absolute, free, available, used, maximum, minimum, ret): + unit = 'KB' if absolute else '%' + if minimum is not None: + if free: + if available < minimum: + ret['comment'] = ('Disk available space is below minimum' + ' of {0} {2} at {1} {2}' + ''.format(minimum, available, unit) + ) + return ret + else: + if used < minimum: + ret['comment'] = ('Disk used space is below minimum' + ' of {0} {2} at {1} {2}' + ''.format(minimum, used, unit) + ) + return ret + if maximum is not None: + if free: + if available > maximum: + ret['comment'] = ('Disk available space is above maximum' + ' of {0} {2} at {1} {2}' + ''.format(maximum, available, unit) + ) + return ret + else: + if used > maximum: + ret['comment'] = ('Disk used space is above maximum' + ' of {0} {2} at {1} {2}' + ''.format(maximum, used, unit) + ) + return ret + ret['comment'] = 'Disk used space in acceptable range' + ret['result'] = True + return ret + + +def status(name, maximum=None, minimum=None, absolute=False, free=False): ''' Return the current disk usage stats for the named mount point name - Disk mount with which to check used space + Disk mount or directory for which to check used space maximum The maximum disk utilization @@ -92,6 +169,10 @@ def status(name, maximum=None, minimum=None, absolute=False): the `absolute` flag to use kilobytes. .. versionadded:: 2016.11.0 + + free + By default, `minimum` & `maximum` refer to the amount of used space. + Set to `True` to evaluate the free space instead. ''' # Monitoring state, no changes will be made so no test interface needed ret = {'name': name, @@ -100,13 +181,6 @@ def status(name, maximum=None, minimum=None, absolute=False): 'changes': {}, 'data': {}} # Data field for monitoring state - data = __salt__['disk.usage']() - - # Validate name - if name not in data: - ret['result'] = False - ret['comment'] += 'Named disk mount not present ' - return ret # Validate extrema if maximum is not None: if not absolute: @@ -126,30 +200,11 @@ def status(name, maximum=None, minimum=None, absolute=False): if ret['comment']: return ret - # Get used space - if absolute: - used = int(data[name]['used']) - else: - # POSIX-compliant df output reports percent used as 'capacity' - used = int(data[name]['capacity'].strip('%')) + data = __salt__['disk.usage']() - # Collect return information - ret['data'] = data[name] - unit = 'KB' if absolute else '%' - if minimum is not None: - if used < minimum: - ret['comment'] = ('Disk used space is below minimum' - ' of {0} {2} at {1} {2}' - ''.format(minimum, used, unit) - ) - return ret - if maximum is not None: - if used > maximum: - ret['comment'] = ('Disk used space is above maximum' - ' of {0} {2} at {1} {2}' - ''.format(maximum, used, unit) - ) - return ret - ret['comment'] = 'Disk used space in acceptable range' - ret['result'] = True - return ret + # Validate name + if name not in data: + ret['comment'] += ('Disk mount {0} not present. '.format(name)) + return _status_path(name, ret, minimum, maximum, absolute, free) + else: + return _status_mount(name, ret, minimum, maximum, absolute, free, data) diff --git a/salt/states/file.py b/salt/states/file.py index 84167da578f3..a9287dce22b5 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -6417,7 +6417,6 @@ def rename(name, source, force=False, makedirs=False): if not force: ret['comment'] = ('The target file "{0}" exists and will not be ' 'overwritten'.format(name)) - ret['result'] = False return ret elif not __opts__['test']: # Remove the destination to prevent problems later diff --git a/salt/states/hipchat.py b/salt/states/hipchat.py deleted file mode 100644 index cb31d58dd9c7..000000000000 --- a/salt/states/hipchat.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- coding: utf-8 -*- -''' -Send a message to Hipchat -========================= - -This state is useful for sending messages to Hipchat during state runs. - -The property api_url is optional. By defaul will use the public HipChat API at https://api.hipchat.com - -.. versionadded:: 2015.5.0 - -.. code-block:: yaml - - hipchat-message: - hipchat.send_message: - - room_id: 123456 - - from_name: SuperAdmin - - message: 'This state was executed successfully.' - - api_url: https://hipchat.myteam.com - - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15 - - api_version: v1 - -The api key can be specified in the master or minion configuration like below: - -.. code-block:: yaml - - hipchat: - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15 - api_version: v1 - -''' - -# Import Python libs -from __future__ import absolute_import, print_function, unicode_literals - - -def __virtual__(): - ''' - Only load if the hipchat module is available in __salt__ - ''' - return 'hipchat' if 'hipchat.send_message' in __salt__ else False - - -def send_message(name, - room_id, - from_name, - message, - api_url=None, - api_key=None, - api_version=None, - message_color='yellow', - notify=False): - ''' - Send a message to a Hipchat room. - - .. code-block:: yaml - - hipchat-message: - hipchat.send_message: - - room_id: 123456 - - from_name: SuperAdmin - - message: 'This state was executed successfully.' - - api_url: https://hipchat.myteam.com - - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15 - - api_version: v1 - - message_color: green - - notify: True - - The following parameters are required: - - name - The unique name for this event. - - room_id - The room to send the message to. Can either be the ID or the name. - - from_name - The name of that is to be shown in the "from" field. - If not specified, defaults to. - - message - The message that is to be sent to the Hipchat room. - - The following parameters are optional: - - api_url - The API URl to be used. - If not specified here or in the configuration options of master or minion, - will use the public HipChat API: https://api.hipchat.com - - api_key - The api key for Hipchat to use for authentication, - if not specified in the configuration options of master or minion. - - api_version - The api version for Hipchat to use, - if not specified in the configuration options of master or minion. - - message_color - The color the Hipchat message should be displayed in. One of the following, default: yellow - "yellow", "red", "green", "purple", "gray", or "random". - - notify - Should a notification in the room be raised. - ''' - ret = {'name': name, - 'changes': {}, - 'result': False, - 'comment': ''} - - if __opts__['test']: - ret['comment'] = 'The following message is to be sent to Hipchat: {0}'.format(message) - ret['result'] = None - return ret - - if not room_id: - ret['comment'] = 'Hipchat room id is missing: {0}'.format(name) - return ret - - if not from_name: - ret['comment'] = 'Hipchat from name is missing: {0}'.format(name) - return ret - - if not message: - ret['comment'] = 'Hipchat message is missing: {0}'.format(name) - return ret - - ret['result'] = __salt__['hipchat.send_message']( - room_id=room_id, - message=message, - from_name=from_name, - api_url=api_url, - api_key=api_key, - api_version=api_version, - color=message_color, - notify=notify, - ) - - if ret and ret['result']: - ret['comment'] = 'Sent message: {0}'.format(name) - else: - ret['comment'] = 'Failed to send message: {0}'.format(name) - - return ret diff --git a/salt/states/mdadm_raid.py b/salt/states/mdadm_raid.py index fd285b6acee2..d634522c334e 100644 --- a/salt/states/mdadm_raid.py +++ b/salt/states/mdadm_raid.py @@ -98,7 +98,7 @@ def present(name, if dev == 'missing' or not __salt__['file.access'](dev, 'f'): missing.append(dev) continue - superblock = __salt__['raid.examine'](dev) + superblock = __salt__['raid.examine'](dev, quiet=True) if 'MD_UUID' in superblock: uuid = superblock['MD_UUID'] diff --git a/salt/states/pip_state.py b/salt/states/pip_state.py index a9b2995e09e1..1134c059786b 100644 --- a/salt/states/pip_state.py +++ b/salt/states/pip_state.py @@ -901,6 +901,7 @@ def installed(name, use_vt=use_vt, trusted_host=trusted_host, no_cache_dir=no_cache_dir, + disable_version_check=True, **kwargs ) diff --git a/salt/states/pkgrepo.py b/salt/states/pkgrepo.py index 4d5e9eea92fc..d52ebcc1a5cc 100644 --- a/salt/states/pkgrepo.py +++ b/salt/states/pkgrepo.py @@ -230,7 +230,7 @@ def managed(name, ppa=None, **kwargs): Included to reduce confusion due to YUM/DNF/Zypper's use of the ``enabled`` argument. If this is passed for an APT-based distro, then the reverse will be passed as ``disabled``. For example, passing - ``enabled=False`` will assume ``disabled=False``. + ``enabled=False`` will assume ``disabled=True``. architectures On apt-based systems, architectures can restrict the available diff --git a/salt/states/saltutil.py b/salt/states/saltutil.py index bb6f8cd493d6..3803abf18de0 100644 --- a/salt/states/saltutil.py +++ b/salt/states/saltutil.py @@ -143,6 +143,20 @@ def sync_grains(name, **kwargs): return _sync_single(name, "grains", **kwargs) +def sync_executors(name, **kwargs): + ''' + Performs the same task as saltutil.sync_executors module + See :mod:`saltutil module for full list of options ` + + .. code-block:: yaml + + sync_everything: + saltutil.sync_executors: + - refresh: True + ''' + return _sync_single(name, "executors", **kwargs) + + def sync_log_handlers(name, **kwargs): ''' Performs the same task as saltutil.sync_log_handlers module diff --git a/salt/states/user.py b/salt/states/user.py index 523c16611658..7b05e277c749 100644 --- a/salt/states/user.py +++ b/salt/states/user.py @@ -161,13 +161,13 @@ def _changes(name, if fullname is not None and lusr['fullname'] != fullname: change['fullname'] = fullname if win_homedrive and lusr['homedrive'] != win_homedrive: - change['homedrive'] = win_homedrive + change['win_homedrive'] = win_homedrive if win_profile and lusr['profile'] != win_profile: - change['profile'] = win_profile + change['win_profile'] = win_profile if win_logonscript and lusr['logonscript'] != win_logonscript: - change['logonscript'] = win_logonscript + change['win_logonscript'] = win_logonscript if win_description and lusr['description'] != win_description: - change['description'] = win_description + change['win_description'] = win_description # MacOS doesn't have full GECOS support, so check for the "ch" functions # and ignore these parameters if these functions do not exist. diff --git a/salt/states/zpool.py b/salt/states/zpool.py index ca8dd86dc9f2..683f95f92ec2 100644 --- a/salt/states/zpool.py +++ b/salt/states/zpool.py @@ -9,8 +9,8 @@ .. versionadded:: 2016.3.0 .. versionchanged:: 2018.3.1 - Big refactor to remove duplicate code, better type converions and improved - consistancy in output. + Big refactor to remove duplicate code, better type conversions and improved + consistency in output. .. code-block:: yaml @@ -387,7 +387,7 @@ def absent(name, export=False, force=False): name : string name of storage pool export : boolean - export instread of destroy the zpool if present + export instead of destroy the zpool if present force : boolean force destroy or export diff --git a/salt/templates/rh_ip/rh8_eth.jinja b/salt/templates/rh_ip/rh8_eth.jinja new file mode 100644 index 000000000000..83604a214ebf --- /dev/null +++ b/salt/templates/rh_ip/rh8_eth.jinja @@ -0,0 +1,56 @@ +DEVICE="{{name}}" +{% if nickname %}NAME="{{nickname}}" +{%endif%}{% if hwaddr %}HWADDR="{{hwaddr}}" +{%endif%}{% if macaddr %}MACADDR="{{macaddr}}" +{%endif%}{% if uuid %}UUID="{{uuid}}" +{%endif%}{% if userctl %}USERCTL="{{userctl}}" +{%endif%}{% if master %}MASTER="{{master}}" +{%endif%}{% if slave %}SLAVE="{{slave}}" +{%endif%}{% if vlan %}VLAN="{{vlan}}" +{% if reorder_hdr %}REORDER_HDR="{{reorder_hdr}}" +{%endif%}{% if vlan_id %}VID="{{vlan_id}}" +{%endif%}{% if phys_dev %}PHYSDEV="{{phys_dev}}" +{%endif%}{%endif%}{% if devtype %}TYPE="{{devtype}}" +{%endif%}{% if proto %}BOOTPROTO="{{proto}}" +{%endif%}{% if onboot %}ONBOOT="{{onboot}}" +{%endif%}{% if onparent %}ONPARENT={{onparent}} +{%endif%}{% if ipv4_failure_fatal %}IPV4_FAILURE_FATAL="{{ipv4_failure_fatal}}" +{%endif%}{% if ipaddr %}IPADDR="{{ipaddr}}" +{%endif%}{% if ipaddr_start %}IPADDR_START="{{ipaddr_start}}" +{%endif%}{% if ipaddr_end %}IPADDR_END="{{ipaddr_end}}" +{%endif%}{% if clonenum_start %}CLONENUM_START="{{clonenum_start}}" +{%endif%}{% if netmask %}NETMASK="{{netmask}}" +{%endif%}{% if prefix %}PREFIX="{{prefix}}" +{%endif%}{% if ipaddrs %}{% for i in ipaddrs -%} +IPADDR{{loop.index}}="{{i['ipaddr']}}" +PREFIX{{loop.index}}="{{i['prefix']}}" +{% endfor -%} +{%endif%}{% if gateway %}GATEWAY="{{gateway}}" +{%endif%}{% if enable_ipv6 %}IPV6INIT="yes" +{% if ipv6_autoconf %}IPV6_AUTOCONF="{{ipv6_autoconf}}" +{%endif%}{% if dhcpv6c %}DHCPV6C="{{dhcpv6c}}" +{%endif%}{% if ipv6addr %}IPV6ADDR="{{ipv6addr}}" +{%endif%}{% if ipv6gateway %}IPV6_DEFAULTGW="{{ipv6gateway}}" +{%endif%}{% if ipv6addrs %}IPV6ADDR_SECONDARIES="{{ ipv6addrs|join(' ') }}" +{%endif%}{% if ipv6_peerdns %}IPV6_PEERDNS="{{ipv6_peerdns}}" +{%endif%}{% if ipv6_defroute %}IPV6_DEFROUTE="{{ipv6_defroute}}" +{%endif%}{% if ipv6_peerroutes %}IPV6_PEERROUTES="{{ipv6_peerroutes}}" +{%endif%}{%endif%}{% if srcaddr %}SRCADDR="{{srcaddr}}" +{%endif%}{% if peerdns %}PEERDNS="{{peerdns}}" +{%endif%}{% if peerroutes %}PEERROUTES="{{peerroutes}}" +{%endif%}{% if peerntp %}PEERNTP="{{peerntp}}" +{%endif%}{% if defroute %}DEFROUTE="{{defroute}}" +{%endif%}{% if bridge %}BRIDGE="{{bridge}}" +{%endif%}{% if stp %}STP="{{stp}}" +{%endif%}{% if delay or delay == 0 %}DELAY="{{delay}}" +{%endif%}{% if mtu %}MTU="{{mtu}}" +{%endif%}{% if zone %}ZONE="{{zone}}" +{%endif%}{% if my_inner_ipaddr %}MY_INNER_IPADDR={{my_inner_ipaddr}} +{%endif%}{% if my_outer_ipaddr %}MY_OUTER_IPADDR={{my_outer_ipaddr}} +{%endif%}{% if bonding %}BONDING_OPTS="{%for item in bonding %}{{item}}={{bonding[item]}} {%endfor%}" +{%endif%}{% if ethtool %}ETHTOOL_OPTS="{%for item in ethtool %}{{item}} {{ethtool[item]}} {%endfor%}" +{%endif%}{% if domain %}DOMAIN="{{ domain|join(' ') }}" +{%endif%}{% if nm_controlled %}NM_CONTROLLED="{{nm_controlled}}" +{% endif %}{% for server in dns -%} +DNS{{loop.index}}="{{server}}" +{% endfor -%} diff --git a/salt/transport/ipc.py b/salt/transport/ipc.py index dbcba18e5c5d..a0d26dd95fde 100644 --- a/salt/transport/ipc.py +++ b/salt/transport/ipc.py @@ -5,6 +5,7 @@ # Import Python libs from __future__ import absolute_import, print_function, unicode_literals +import sys import errno import logging import socket @@ -341,10 +342,6 @@ def _connect(self, timeout=None): def __del__(self): try: self.close() - except socket.error as exc: - if exc.errno != errno.EBADF: - # If its not a bad file descriptor error, raise - raise except TypeError: # This is raised when Python's GC has collected objects which # would be needed when calling self.close() @@ -364,7 +361,12 @@ def close(self): log.debug('Closing %s instance', self.__class__.__name__) if self.stream is not None and not self.stream.closed(): - self.stream.close() + try: + self.stream.close() + except socket.error as exc: + if exc.errno != errno.EBADF: + # If its not a bad file descriptor error, raise + six.reraise(*sys.exc_info()) class IPCMessageClient(IPCClient): diff --git a/salt/utils/immutabletypes.py b/salt/utils/immutabletypes.py index 017458402e58..b474d1bd1e97 100644 --- a/salt/utils/immutabletypes.py +++ b/salt/utils/immutabletypes.py @@ -9,6 +9,7 @@ Immutable types ''' from __future__ import absolute_import, unicode_literals +import copy # Import python libs try: @@ -37,6 +38,15 @@ def __getitem__(self, key): def __repr__(self): return '<{0} {1}>'.format(self.__class__.__name__, repr(self.__obj)) + def __deepcopy__(self, memo): + return copy.deepcopy(self.__obj) + + def copy(self): + ''' + Return an un-frozen copy of self + ''' + return copy.deepcopy(self.__obj) + class ImmutableList(Sequence): ''' @@ -64,6 +74,9 @@ def __getitem__(self, key): def __repr__(self): return '<{0} {1}>'.format(self.__class__.__name__, repr(self.__obj)) + def __deepcopy__(self, memo): + return copy.deepcopy(self.__obj) + class ImmutableSet(Set): ''' @@ -85,6 +98,9 @@ def __contains__(self, key): def __repr__(self): return '<{0} {1}>'.format(self.__class__.__name__, repr(self.__obj)) + def __deepcopy__(self, memo): + return copy.deepcopy(self.__obj) + def freeze(obj): ''' diff --git a/salt/utils/listdiffer.py b/salt/utils/listdiffer.py index 5c1a77ea7707..96594365a5ef 100644 --- a/salt/utils/listdiffer.py +++ b/salt/utils/listdiffer.py @@ -237,7 +237,7 @@ def changed(self, selection='all'): changed.append('.'.join([self._key, key_val, change])) return changed elif selection == 'intersect': - # We want the unset values as well + # We want the unset values as well for recursive_item in self._get_recursive_difference(type='intersect'): recursive_item.ignore_unset_values = False key_val = six.text_type(recursive_item.past_dict[self._key]) \ diff --git a/salt/utils/pkg/rpm.py b/salt/utils/pkg/rpm.py index 208c2f548f7e..bc5eb30eda0d 100644 --- a/salt/utils/pkg/rpm.py +++ b/salt/utils/pkg/rpm.py @@ -21,7 +21,7 @@ # These arches compiled from the rpmUtils.arch python module source ARCHES_64 = ('x86_64', 'athlon', 'amd64', 'ia32e', 'ia64', 'geode') ARCHES_32 = ('i386', 'i486', 'i586', 'i686') -ARCHES_PPC = ('ppc', 'ppc64', 'ppc64iseries', 'ppc64pseries') +ARCHES_PPC = ('ppc', 'ppc64', 'ppc64le', 'ppc64iseries', 'ppc64pseries') ARCHES_S390 = ('s390', 's390x') ARCHES_SPARC = ( 'sparc', 'sparcv8', 'sparcv9', 'sparcv9v', 'sparc64', 'sparc64v' diff --git a/salt/utils/schedule.py b/salt/utils/schedule.py index 8c0d987021c3..b32c8ede0aa6 100644 --- a/salt/utils/schedule.py +++ b/salt/utils/schedule.py @@ -1662,7 +1662,7 @@ def _run_job(self, func, data): run_schedule_jobs_in_background = self.opts.get('run_schedule_jobs_in_background', True) if run_schedule_jobs_in_background is False: - # Explicitly pass False for multiprocessing_enabled + # Explicitly pass False for multiprocessing_enabled self.handle_func(False, func, data) return diff --git a/salt/utils/yamldumper.py b/salt/utils/yamldumper.py index c4597f5bb4ad..4980ce3b18ae 100644 --- a/salt/utils/yamldumper.py +++ b/salt/utils/yamldumper.py @@ -59,8 +59,13 @@ def represent_ordereddict(dumper, data): return dumper.represent_dict(list(data.items())) +def represent_undefined(dumper, data): + return dumper.represent_scalar(u'tag:yaml.org,2002:null', u'NULL') + + OrderedDumper.add_representer(OrderedDict, represent_ordereddict) SafeOrderedDumper.add_representer(OrderedDict, represent_ordereddict) +SafeOrderedDumper.add_representer(None, represent_undefined) OrderedDumper.add_representer( collections.defaultdict, diff --git a/salt/utils/zfs.py b/salt/utils/zfs.py index b0d1af15f3ec..628d2448fd53 100644 --- a/salt/utils/zfs.py +++ b/salt/utils/zfs.py @@ -123,7 +123,7 @@ def _property_parse_cmd(cmd, alias=None): # NOTE: parse output prop_hdr = [] for prop_data in _exec(cmd=cmd)['stderr'].split('\n'): - # NOTE: make the line data more managable + # NOTE: make the line data more manageable prop_data = prop_data.lower().split() # NOTE: skip empty lines @@ -217,7 +217,7 @@ def _command(source, command, flags=None, opts=None, cmd.append(flag) # NOTE: append options - # we pass through 'sorted' to garentee the same order + # we pass through 'sorted' to guarantee the same order if opts is None: opts = {} for opt in sorted(opts): @@ -228,7 +228,7 @@ def _command(source, command, flags=None, opts=None, cmd.append(to_str(val)) # NOTE: append filesystem properties (really just options with a key/value) - # we pass through 'sorted' to garentee the same order + # we pass through 'sorted' to guarantee the same order if filesystem_properties is None: filesystem_properties = {} for fsopt in sorted(filesystem_properties): @@ -239,7 +239,7 @@ def _command(source, command, flags=None, opts=None, )) # NOTE: append pool properties (really just options with a key/value) - # we pass through 'sorted' to garentee the same order + # we pass through 'sorted' to guarantee the same order if pool_properties is None: pool_properties = {} for fsopt in sorted(pool_properties): @@ -330,8 +330,8 @@ def property_data_zpool(): .. warning:: - This data is probed from the output of 'zpool get' with some suplimental - data that is hardcoded. There is no better way to get this informatio aside + This data is probed from the output of 'zpool get' with some supplemental + data that is hardcoded. There is no better way to get this information aside from reading the code. ''' @@ -387,8 +387,8 @@ def property_data_zfs(): .. warning:: - This data is probed from the output of 'zfs get' with some suplimental - data that is hardcoded. There is no better way to get this informatio aside + This data is probed from the output of 'zfs get' with some supplemental + data that is hardcoded. There is no better way to get this information aside from reading the code. ''' @@ -476,7 +476,7 @@ def to_bool_alt(value): def from_size(value): ''' - Convert zfs size (human readble) to python int (bytes) + Convert zfs size (human readable) to python int (bytes) ''' match_size = re_zfs_size.match(str(value)) if match_size: @@ -676,7 +676,7 @@ def parse_command_result(res, label=None): .. note:: - Output on failure is rather predicatable. + Output on failure is rather predictable. - retcode > 0 - each 'error' is a line on stderr - optional 'Usage:' block under those with hits diff --git a/tests/conftest.py b/tests/conftest.py index e84436edaae7..3f68aef80bcc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -244,24 +244,24 @@ def pytest_runtest_setup(item): ''' Fixtures injection based on markers or test skips based on CLI arguments ''' - destructive_tests_marker = item.get_marker('destructive_test') + destructive_tests_marker = item.get_closest_marker('destructive_test') if destructive_tests_marker is not None: if item.config.getoption('--run-destructive') is False: pytest.skip('Destructive tests are disabled') os.environ['DESTRUCTIVE_TESTS'] = six.text_type(item.config.getoption('--run-destructive')) - expensive_tests_marker = item.get_marker('expensive_test') + expensive_tests_marker = item.get_closest_marker('expensive_test') if expensive_tests_marker is not None: if item.config.getoption('--run-expensive') is False: pytest.skip('Expensive tests are disabled') os.environ['EXPENSIVE_TESTS'] = six.text_type(item.config.getoption('--run-expensive')) - skip_if_not_root_marker = item.get_marker('skip_if_not_root') + skip_if_not_root_marker = item.get_closest_marker('skip_if_not_root') if skip_if_not_root_marker is not None: if os.getuid() != 0: pytest.skip('You must be logged in as root to run this test') - skip_if_binaries_missing_marker = item.get_marker('skip_if_binaries_missing') + skip_if_binaries_missing_marker = item.get_closest_marker('skip_if_binaries_missing') if skip_if_binaries_missing_marker is not None: binaries = skip_if_binaries_missing_marker.args if len(binaries) == 1: @@ -286,7 +286,7 @@ def pytest_runtest_setup(item): ) ) - requires_network_marker = item.get_marker('requires_network') + requires_network_marker = item.get_closest_marker('requires_network') if requires_network_marker is not None: only_local_network = requires_network_marker.kwargs.get('only_local_network', False) has_local_network = False diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 2bfd91760dbb..d5e9a9a03bfb 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -705,6 +705,9 @@ def client(self): def transplant_configs(cls, transport='zeromq'): if os.path.isdir(RUNTIME_VARS.TMP_CONF_DIR): shutil.rmtree(RUNTIME_VARS.TMP_CONF_DIR) + if os.path.isdir(RUNTIME_VARS.TMP_ROOT_DIR): + shutil.rmtree(RUNTIME_VARS.TMP_ROOT_DIR) + os.makedirs(RUNTIME_VARS.TMP_ROOT_DIR) os.makedirs(RUNTIME_VARS.TMP_CONF_DIR) os.makedirs(RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR) os.makedirs(RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR) @@ -719,11 +722,11 @@ def transplant_configs(cls, transport='zeromq'): # This master connects to syndic_master via a syndic master_opts = salt.config._read_conf_file(os.path.join(RUNTIME_VARS.CONF_DIR, 'master')) master_opts['known_hosts_file'] = tests_known_hosts_file - master_opts['cachedir'] = os.path.join(TMP, 'rootdir', 'cache') + master_opts['cachedir'] = os.path.join(TMP_ROOT_DIR, 'cache') master_opts['user'] = RUNTIME_VARS.RUNNING_TESTS_USER master_opts['config_dir'] = RUNTIME_VARS.TMP_CONF_DIR - master_opts['root_dir'] = os.path.join(TMP, 'rootdir') - master_opts['pki_dir'] = os.path.join(TMP, 'rootdir', 'pki', 'master') + master_opts['root_dir'] = os.path.join(TMP_ROOT_DIR) + master_opts['pki_dir'] = os.path.join(TMP_ROOT_DIR, 'pki', 'master') master_opts['syndic_master'] = 'localhost' file_tree = { 'root_dir': os.path.join(FILES, 'pillar', 'base', 'file_tree'), @@ -771,13 +774,13 @@ def transplant_configs(cls, transport='zeromq'): # This minion connects to master minion_opts = salt.config._read_conf_file(os.path.join(RUNTIME_VARS.CONF_DIR, 'minion')) - minion_opts['cachedir'] = os.path.join(TMP, 'rootdir', 'cache') + minion_opts['cachedir'] = os.path.join(TMP_ROOT_DIR, 'cache') minion_opts['user'] = RUNTIME_VARS.RUNNING_TESTS_USER minion_opts['config_dir'] = RUNTIME_VARS.TMP_CONF_DIR - minion_opts['root_dir'] = os.path.join(TMP, 'rootdir') - minion_opts['pki_dir'] = os.path.join(TMP, 'rootdir', 'pki') - minion_opts['hosts.file'] = os.path.join(TMP, 'rootdir', 'hosts') - minion_opts['aliases.file'] = os.path.join(TMP, 'rootdir', 'aliases') + minion_opts['root_dir'] = os.path.join(TMP_ROOT_DIR) + minion_opts['pki_dir'] = os.path.join(TMP_ROOT_DIR, 'pki') + minion_opts['hosts.file'] = os.path.join(TMP_ROOT_DIR, 'hosts') + minion_opts['aliases.file'] = os.path.join(TMP_ROOT_DIR, 'aliases') if virtualenv_binary: minion_opts['venv_bin'] = virtualenv_binary @@ -788,8 +791,8 @@ def transplant_configs(cls, transport='zeromq'): sub_minion_opts['config_dir'] = RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR sub_minion_opts['root_dir'] = os.path.join(TMP, 'rootdir-sub-minion') sub_minion_opts['pki_dir'] = os.path.join(TMP, 'rootdir-sub-minion', 'pki', 'minion') - sub_minion_opts['hosts.file'] = os.path.join(TMP, 'rootdir', 'hosts') - sub_minion_opts['aliases.file'] = os.path.join(TMP, 'rootdir', 'aliases') + sub_minion_opts['hosts.file'] = os.path.join(TMP_ROOT_DIR, 'hosts') + sub_minion_opts['aliases.file'] = os.path.join(TMP_ROOT_DIR, 'aliases') if virtualenv_binary: sub_minion_opts['venv_bin'] = virtualenv_binary @@ -801,6 +804,15 @@ def transplant_configs(cls, transport='zeromq'): syndic_master_opts['root_dir'] = os.path.join(TMP, 'rootdir-syndic-master') syndic_master_opts['pki_dir'] = os.path.join(TMP, 'rootdir-syndic-master', 'pki', 'master') + # This is the syndic for master + # Let's start with a copy of the syndic master configuration + syndic_opts = copy.deepcopy(syndic_master_opts) + # Let's update with the syndic configuration + syndic_opts.update(salt.config._read_conf_file(os.path.join(RUNTIME_VARS.CONF_DIR, 'syndic'))) + syndic_opts['config_dir'] = RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR + syndic_opts['cachedir'] = os.path.join(TMP_ROOT_DIR, 'cache') + syndic_opts['root_dir'] = os.path.join(TMP_ROOT_DIR) + # This proxy connects to master proxy_opts = salt.config._read_conf_file(os.path.join(CONF_DIR, 'proxy')) proxy_opts['cachedir'] = os.path.join(TMP, 'rootdir-proxy', 'cache') diff --git a/tests/integration/cloud/clouds/test_virtualbox.py b/tests/integration/cloud/clouds/test_virtualbox.py index c0f12269fbc7..1cd7c5966fdc 100644 --- a/tests/integration/cloud/clouds/test_virtualbox.py +++ b/tests/integration/cloud/clouds/test_virtualbox.py @@ -9,8 +9,8 @@ import socket # Import Salt Testing Libs -import tests.integration as integration from tests.support.unit import TestCase, skipIf +from tests.support.runtests import RUNTIME_VARS from tests.integration.cloud.helpers.virtualbox import (VirtualboxTestCase, VirtualboxCloudTestCase, CONFIG_NAME, @@ -87,7 +87,7 @@ def setUp(self): # check if personal access token, ssh_key_file, and ssh_key_names are present config_path = os.path.join( - integration.FILES, + RUNTIME_VARS.FILES, 'conf', 'cloud.providers.d', PROVIDER_NAME + '.conf' @@ -96,7 +96,7 @@ def setUp(self): providers = cloud_providers_config(config_path) log.debug("config: %s", providers) config_path = os.path.join( - integration.FILES, + RUNTIME_VARS.FILES, 'conf', 'cloud.profiles.d', PROVIDER_NAME + '.conf' @@ -251,7 +251,7 @@ def setUp(self): # check if personal access token, ssh_key_file, and ssh_key_names are present config_path = os.path.join( - integration.FILES, + RUNTIME_VARS.FILES, 'conf', 'cloud.providers.d', PROVIDER_NAME + '.conf' @@ -260,7 +260,7 @@ def setUp(self): providers = cloud_providers_config(config_path) log.debug("config: %s", providers) config_path = os.path.join( - integration.FILES, + RUNTIME_VARS.FILES, 'conf', 'cloud.profiles.d', PROVIDER_NAME + '.conf' diff --git a/tests/integration/cloud/clouds/test_vultrpy.py b/tests/integration/cloud/clouds/test_vultrpy.py index f0dc58e309e7..c91281440388 100644 --- a/tests/integration/cloud/clouds/test_vultrpy.py +++ b/tests/integration/cloud/clouds/test_vultrpy.py @@ -45,10 +45,7 @@ def test_list_sizes(self): Tests the return of running the --list-sizes command for Vultr ''' size_list = self.run_cloud('--list-sizes {0}'.format(self.PROVIDER)) - self.assertIn( - '32768 MB RAM,4x110 GB SSD,40.00 TB BW', - [i.strip() for i in size_list] - ) + self.assertIn('2048 MB RAM,64 GB SSD,2.00 TB BW', [i.strip() for i in size_list]) # Commented for now, Vultr driver does not yet support key management # def test_key_management(self): diff --git a/tests/integration/executors/__init__.py b/tests/integration/executors/__init__.py new file mode 100644 index 000000000000..40a96afc6ff0 --- /dev/null +++ b/tests/integration/executors/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/tests/integration/files/file/base/_executors/arg.py b/tests/integration/files/file/base/_executors/arg.py new file mode 100644 index 000000000000..dfe09cb7b834 --- /dev/null +++ b/tests/integration/files/file/base/_executors/arg.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- + + +def __virtual__(): + return True + + +def execute(*args, **kwargs): + # we use the dunder to assert the loader is provided minionmods + return __salt__['test.arg']('test.arg fired') diff --git a/tests/integration/files/file/base/retry/retry_success.sls b/tests/integration/files/file/base/retry/retry_success.sls index 7497d14f1944..f7cddb5f0008 100644 --- a/tests/integration/files/file/base/retry/retry_success.sls +++ b/tests/integration/files/file/base/retry/retry_success.sls @@ -1,10 +1,10 @@ -{{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file') }}: +{{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file_option_success') }}: file: - touch file_test: file.exists: - - name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file') }} + - name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file_option_success') }} - retry: until: True attempts: 5 diff --git a/tests/integration/files/file/base/retry/retry_success2.sls b/tests/integration/files/file/base/retry/retry_success2.sls index daa08c5e0085..9fefb2cef461 100644 --- a/tests/integration/files/file/base/retry/retry_success2.sls +++ b/tests/integration/files/file/base/retry/retry_success2.sls @@ -1,7 +1,14 @@ -file_test: +file_test_a: + file.managed: + - name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file_eventual_success') + '_a' }} + - content: 'a' + +file_test_b: file.exists: - - name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file') }} + - name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('retry_file_eventual_success') }} - retry: until: True attempts: 20 interval: 5 + - require: + - file_test_a diff --git a/tests/integration/grains/test_core.py b/tests/integration/grains/test_core.py index 72171b8bdace..b523d58cfb5d 100644 --- a/tests/integration/grains/test_core.py +++ b/tests/integration/grains/test_core.py @@ -59,7 +59,7 @@ class TestGrainsReg(ModuleCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils(opts, whitelist=['reg']) return { salt.modules.reg: { diff --git a/tests/integration/master/test_event_return.py b/tests/integration/master/test_event_return.py index c80540e26540..77598361cfea 100644 --- a/tests/integration/master/test_event_return.py +++ b/tests/integration/master/test_event_return.py @@ -20,9 +20,10 @@ from tests.support.paths import ScriptPathMixin from tests.support.helpers import get_unused_localhost_port from tests.support.mixins import AdaptedConfigurationTestCaseMixin +from tests.support.processes import terminate_process # Import 3rd-party libs -from tests.support.processes import terminate_process +import pytest # Import Salt libs import salt.ext.six as six @@ -49,6 +50,8 @@ def setUpClass(cls): temp_config = AdaptedConfigurationTestCaseMixin.get_temp_config('master', **overrides) cls.root_dir = temp_config['root_dir'] cls.config_dir = os.path.dirname(temp_config['conf_file']) + if temp_config['transport'] == 'tcp': + pytest.skip('Test only applicable to the ZMQ transport') @classmethod def tearDownClass(cls): diff --git a/tests/integration/minion/test_executor.py b/tests/integration/minion/test_executor.py new file mode 100644 index 000000000000..93e9c57ffdb3 --- /dev/null +++ b/tests/integration/minion/test_executor.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +# Import python libs +from __future__ import absolute_import, print_function, unicode_literals + +import logging + +# Import Salt Testing libs +from tests.support.case import ModuleCase, ShellCase + +log = logging.getLogger(__name__) + + +class ExecutorTest(ModuleCase, ShellCase): + + def setup(self): + self.run_function('saltutil.sync_all') + + def test_executor(self): + ''' + test that dunders are set + ''' + data = self.run_call('test.arg --module-executors=arg') + self.assertIn('test.arg fired', "".join(data)) diff --git a/tests/integration/modules/test_network.py b/tests/integration/modules/test_network.py index 0738fbb97d6d..09176b317a30 100644 --- a/tests/integration/modules/test_network.py +++ b/tests/integration/modules/test_network.py @@ -23,7 +23,7 @@ def test_network_ping(self): network.ping ''' ret = self.run_function('network.ping', [URL]) - exp_out = ['ping', URL, 'ttl', 'time'] + exp_out = ['ping', URL, 'ms', 'time'] for out in exp_out: self.assertIn(out, ret.lower()) diff --git a/tests/integration/modules/test_pkg.py b/tests/integration/modules/test_pkg.py index bb011debfa75..dc3cb6eee897 100644 --- a/tests/integration/modules/test_pkg.py +++ b/tests/integration/modules/test_pkg.py @@ -267,6 +267,9 @@ def test_pkg_upgrade_has_pending_upgrades(self, grains): ''' Test running a system upgrade when there are packages that need upgrading ''' + if grains['os'] == 'Arch': + self.skipTest('Arch moved to Python 3.8 and we\'re not ready for it yet') + func = 'pkg.upgrade' # First make sure that an up-to-date copy of the package db is available diff --git a/tests/integration/modules/test_saltutil.py b/tests/integration/modules/test_saltutil.py index e3c218509809..4a4515c7f2df 100644 --- a/tests/integration/modules/test_saltutil.py +++ b/tests/integration/modules/test_saltutil.py @@ -98,6 +98,7 @@ def test_sync_all(self): 'states': [], 'sdb': [], 'proxymodules': [], + 'executors': [], 'output': [], 'thorium': [], 'serializers': []} @@ -121,6 +122,7 @@ def test_sync_all_whitelist(self): 'states': [], 'sdb': [], 'proxymodules': [], + 'executors': [], 'output': [], 'thorium': [], 'serializers': []} @@ -147,6 +149,7 @@ def test_sync_all_blacklist(self): 'states': [], 'sdb': [], 'proxymodules': [], + 'executors': [], 'output': [], 'thorium': [], 'serializers': []} @@ -163,6 +166,7 @@ def test_sync_all_blacklist_and_whitelist(self): 'beacons': [], 'utils': [], 'returners': [], + 'executors': [], 'modules': [], 'renderers': [], 'log_handlers': [], diff --git a/tests/integration/modules/test_service.py b/tests/integration/modules/test_service.py index 6128a13b5316..e2cc16343eae 100644 --- a/tests/integration/modules/test_service.py +++ b/tests/integration/modules/test_service.py @@ -134,8 +134,8 @@ def test_service_disable_doesnot_exist(self): self.assertTrue(self.run_function('service.disable', [srv_name])) elif self.run_function('grains.item', ['os'])['os'] == 'Debian' and \ self.run_function('grains.item', ['osmajorrelease'])['osmajorrelease'] < 9 and systemd: - # currently disabling a service via systemd that does not exist - # on Debian 8 results in a True return code + # currently disabling a service via systemd that does not exist + # on Debian 8 results in a True return code self.assertTrue(self.run_function('service.disable', [srv_name])) else: try: diff --git a/tests/integration/modules/test_state.py b/tests/integration/modules/test_state.py index 6c9ae55c9ef4..ee32b1f1d999 100644 --- a/tests/integration/modules/test_state.py +++ b/tests/integration/modules/test_state.py @@ -13,7 +13,7 @@ # Import Salt Testing libs from tests.support.case import ModuleCase -from tests.support.helpers import with_tempdir, flaky +from tests.support.helpers import with_tempdir from tests.support.unit import skipIf from tests.support.paths import BASE_FILES, TMP, TMP_PILLAR_TREE, TMP_STATE_TREE from tests.support.mixins import SaltReturnAssertsMixin @@ -1764,7 +1764,7 @@ def test_retry_option_success(self): ''' test a state with the retry option that should return True immedietly (i.e. no retries) ''' - testfile = os.path.join(TMP, 'retry_file') + testfile = os.path.join(TMP, 'retry_file_option_success') state_run = self.run_function( 'state.sls', mods='retry.retry_success' @@ -1773,29 +1773,35 @@ def test_retry_option_success(self): retry_state = 'file_|-file_test_|-{0}_|-exists'.format(testfile) self.assertNotIn('Attempt', state_run[retry_state]['comment']) - def run_create(self): + def run_create(self, testfile): ''' helper function to wait 30 seconds and then create the temp retry file ''' - testfile = os.path.join(TMP, 'retry_file') + # Wait for the requisite stae 'file_test_a' to complete before creating + # test_file + while True: + if os.path.exists(testfile + '_a'): + break + time.sleep(1) time.sleep(30) with salt.utils.files.fopen(testfile, 'a'): pass - @flaky def test_retry_option_eventual_success(self): ''' test a state with the retry option that should return True after at least 4 retry attmempt but never run 15 attempts ''' - testfile = os.path.join(TMP, 'retry_file') - create_thread = threading.Thread(target=self.run_create) + testfile = os.path.join(TMP, 'retry_file_eventual_success') + assert not os.path.exists(testfile + '_a') + assert not os.path.exists(testfile) + create_thread = threading.Thread(target=self.run_create, args=(testfile,)) create_thread.start() state_run = self.run_function( 'state.sls', mods='retry.retry_success2' ) - retry_state = 'file_|-file_test_|-{0}_|-exists'.format(testfile) + retry_state = 'file_|-file_test_b_|-{0}_|-exists'.format(testfile) self.assertIn('Attempt 1:', state_run[retry_state]['comment']) self.assertIn('Attempt 2:', state_run[retry_state]['comment']) self.assertIn('Attempt 3:', state_run[retry_state]['comment']) diff --git a/tests/integration/netapi/rest_tornado/test_app.py b/tests/integration/netapi/rest_tornado/test_app.py index 2c348a679d65..891a4d97094d 100644 --- a/tests/integration/netapi/rest_tornado/test_app.py +++ b/tests/integration/netapi/rest_tornado/test_app.py @@ -2,6 +2,7 @@ # Import Python Libs from __future__ import absolute_import, print_function, unicode_literals +import os import time import threading @@ -36,6 +37,11 @@ def mod_opts(self): @skipIf(HAS_ZMQ_IOLOOP is False, 'PyZMQ version must be >= 14.0.1 to run these tests.') @skipIf(StrictVersion(zmq.__version__) < StrictVersion('14.0.1'), 'PyZMQ must be >= 14.0.1 to run these tests.') class TestSaltAPIHandler(_SaltnadoIntegrationTestCase): + + def setUp(self): + super(TestSaltAPIHandler, self).setUp() + os.environ['ASYNC_TEST_TIMEOUT'] = '300' + def get_app(self): urls = [('/', saltnado.SaltAPIHandler)] @@ -335,7 +341,7 @@ def test_simple_local_runner_post(self): headers={'Content-Type': self.content_type_map['json'], saltnado.AUTH_TOKEN_HEADER: self.token['token']}, connect_timeout=30, - request_timeout=30, + request_timeout=300, ) response_obj = salt.utils.json.loads(response.body) self.assertEqual(len(response_obj['return']), 1) diff --git a/tests/integration/netapi/test_client.py b/tests/integration/netapi/test_client.py index 503bbaf335f5..998454d15166 100644 --- a/tests/integration/netapi/test_client.py +++ b/tests/integration/netapi/test_client.py @@ -32,7 +32,7 @@ def tearDown(self): del self.netapi def test_local(self): - low = {'client': 'local', 'tgt': '*', 'fun': 'test.ping'} + low = {'client': 'local', 'tgt': '*', 'fun': 'test.ping', 'timeout': 300} low.update(self.eauth_creds) ret = self.netapi.run(low) @@ -44,7 +44,7 @@ def test_local(self): self.assertEqual(ret, {'minion': True, 'sub_minion': True}) def test_local_batch(self): - low = {'client': 'local_batch', 'tgt': '*', 'fun': 'test.ping'} + low = {'client': 'local_batch', 'tgt': '*', 'fun': 'test.ping', 'timeout': 300} low.update(self.eauth_creds) ret = self.netapi.run(low) diff --git a/tests/integration/scheduler/test_error.py b/tests/integration/scheduler/test_error.py index f045265ce932..062e8004704e 100644 --- a/tests/integration/scheduler/test_error.py +++ b/tests/integration/scheduler/test_error.py @@ -11,11 +11,9 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch from tests.support.unit import skipIf -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -29,7 +27,7 @@ HAS_CRONITER = False log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/scheduler/test_eval.py b/tests/integration/scheduler/test_eval.py index 2095e7a7ea9e..b2286b8430d5 100644 --- a/tests/integration/scheduler/test_eval.py +++ b/tests/integration/scheduler/test_eval.py @@ -15,11 +15,9 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch from tests.support.unit import skipIf -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -34,7 +32,7 @@ HAS_CRONITER = False log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/scheduler/test_helpers.py b/tests/integration/scheduler/test_helpers.py index 91a8e06f1ed3..55deedc6c232 100644 --- a/tests/integration/scheduler/test_helpers.py +++ b/tests/integration/scheduler/test_helpers.py @@ -9,10 +9,8 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -21,7 +19,7 @@ from salt.modules.test import ping as ping log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/scheduler/test_maxrunning.py b/tests/integration/scheduler/test_maxrunning.py index 063e6e2dc39c..64e19ea6430e 100644 --- a/tests/integration/scheduler/test_maxrunning.py +++ b/tests/integration/scheduler/test_maxrunning.py @@ -11,10 +11,8 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -28,7 +26,7 @@ HAS_CRONITER = False log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/scheduler/test_postpone.py b/tests/integration/scheduler/test_postpone.py index 568f59fb2235..e6912e7b9061 100644 --- a/tests/integration/scheduler/test_postpone.py +++ b/tests/integration/scheduler/test_postpone.py @@ -12,10 +12,8 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -23,7 +21,7 @@ from salt.modules.test import ping as ping log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/scheduler/test_run_job.py b/tests/integration/scheduler/test_run_job.py index c8cdcb6b24b5..8265654149a2 100644 --- a/tests/integration/scheduler/test_run_job.py +++ b/tests/integration/scheduler/test_run_job.py @@ -9,10 +9,8 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -27,7 +25,7 @@ HAS_CRONITER = False log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/scheduler/test_skip.py b/tests/integration/scheduler/test_skip.py index da8e3758ca16..ccbe90fdbd87 100644 --- a/tests/integration/scheduler/test_skip.py +++ b/tests/integration/scheduler/test_skip.py @@ -11,10 +11,8 @@ # Import Salt Testing libs from tests.support.case import ModuleCase from tests.support.mixins import SaltReturnAssertsMixin - -# Import Salt Testing Libs from tests.support.mock import MagicMock, patch -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.utils.schedule @@ -22,7 +20,7 @@ from salt.modules.test import ping as ping log = logging.getLogger(__name__) -ROOT_DIR = os.path.join(integration.TMP, 'schedule-unit-tests') +ROOT_DIR = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') SOCK_DIR = os.path.join(ROOT_DIR, 'test-socks') DEFAULT_CONFIG = salt.config.minion_config(None) diff --git a/tests/integration/shell/test_key.py b/tests/integration/shell/test_key.py index 96d806efcb2a..7a989a490447 100644 --- a/tests/integration/shell/test_key.py +++ b/tests/integration/shell/test_key.py @@ -11,6 +11,7 @@ from tests.support.case import ShellCase from tests.support.paths import TMP from tests.support.mixins import ShellCaseCommonTestsMixin +from tests.support.helpers import skip_if_not_root, destructiveTest # Import 3rd-party libs from salt.ext import six @@ -187,6 +188,8 @@ def test_list_acc(self): expect = ['Accepted Keys:', 'minion', 'sub_minion'] self.assertEqual(data, expect) + @skip_if_not_root + @destructiveTest def test_list_acc_eauth(self): ''' test salt-key -l with eauth @@ -197,6 +200,8 @@ def test_list_acc_eauth(self): self.assertEqual(data, expect) self._remove_user() + @skip_if_not_root + @destructiveTest def test_list_acc_eauth_bad_creds(self): ''' test salt-key -l with eauth and bad creds diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index db006161ad50..205c46b62f52 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -2696,6 +2696,26 @@ def test_binary_contents(self): except OSError: pass + def test_binary_contents_twice(self): + ''' + This test ensures that after a binary file is created, salt can confirm + that the file is in the correct state. + ''' + # Create a binary file + name = os.path.join(TMP, '1px.gif') + + # First run state ensures file is created + ret = self.run_state('file.managed', name=name, contents=BINARY_FILE) + self.assertSaltTrueReturn(ret) + + # Second run of state ensures file is in correct state + ret = self.run_state('file.managed', name=name, contents=BINARY_FILE) + self.assertSaltTrueReturn(ret) + try: + os.remove(name) + except OSError: + pass + @skip_if_not_root @skipIf(not HAS_PWD, "pwd not available. Skipping test") @skipIf(not HAS_GRP, "grp not available. Skipping test") diff --git a/tests/integration/states/test_user.py b/tests/integration/states/test_user.py index a820e97c7cab..a1efae88e513 100644 --- a/tests/integration/states/test_user.py +++ b/tests/integration/states/test_user.py @@ -269,3 +269,39 @@ def tearDown(self): self.assertSaltTrueReturn( self.run_state('user.absent', name=self.user_name) ) + + +@destructiveTest +@skip_if_not_root +@skipIf(not salt.utils.platform.is_windows(), 'Windows only tests') +class WinUserTest(ModuleCase, SaltReturnAssertsMixin): + ''' + test for user absent + ''' + def tearDown(self): + self.assertSaltTrueReturn( + self.run_state('user.absent', name=USER) + ) + + def test_user_present_existing(self): + ret = self.run_state('user.present', + name=USER, + win_homedrive='U:', + win_profile='C:\\User\\{0}'.format(USER), + win_logonscript='C:\\logon.vbs', + win_description='Test User Account') + self.assertSaltTrueReturn(ret) + ret = self.run_state('user.present', + name=USER, + win_homedrive='R:', + win_profile='C:\\Users\\{0}'.format(USER), + win_logonscript='C:\\Windows\\logon.vbs', + win_description='Temporary Account') + self.assertSaltTrueReturn(ret) + self.assertSaltStateChangesEqual(ret, 'R:', keys=['homedrive']) + self.assertSaltStateChangesEqual( + ret, 'C:\\Users\\{0}'.format(USER), keys=['profile']) + self.assertSaltStateChangesEqual( + ret, 'C:\\Windows\\logon.vbs', keys=['logonscript']) + self.assertSaltStateChangesEqual( + ret, 'Temporary Account', keys=['description']) diff --git a/tests/kitchen/tests/wordpress/tests/conftest.py b/tests/kitchen/tests/wordpress/tests/conftest.py index 27d163557b78..c94f18d8fb72 100644 --- a/tests/kitchen/tests/wordpress/tests/conftest.py +++ b/tests/kitchen/tests/wordpress/tests/conftest.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import import functools import os import pytest @@ -10,7 +12,7 @@ else: test_host = testinfra.get_host('paramiko://{KITCHEN_USERNAME}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}'.format(**os.environ), ssh_identity_file=os.environ.get('KITCHEN_SSH_KEY')) -else: +elif 'KITCHEN_USERNAME' in os.environ: test_host = testinfra.get_host('docker://{KITCHEN_USERNAME}@{KITCHEN_CONTAINER_ID}'.format(**os.environ)) diff --git a/tests/support/gitfs.py b/tests/support/gitfs.py index 8a7ee9d9f8f1..104fa9c01cec 100644 --- a/tests/support/gitfs.py +++ b/tests/support/gitfs.py @@ -129,13 +129,12 @@ def start_daemon(daemon_cli_script_name, daemon_class.__name__, attempts ) - return process + break else: terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) time.sleep(1) continue - else: # pylint: disable=useless-else-on-loop - # Wrong, we have a return, its not useless + else: if process is not None: terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) raise AssertionError( @@ -144,6 +143,7 @@ def start_daemon(daemon_cli_script_name, attempts-1 ) ) + return process class SaltDaemonScriptBase(_SaltDaemonScriptBase): diff --git a/tests/support/helpers.py b/tests/support/helpers.py index 267e4682b2ae..7eda1de151a4 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -15,6 +15,7 @@ from __future__ import absolute_import, print_function, unicode_literals import base64 import errno +import fnmatch import functools import inspect import logging @@ -38,13 +39,10 @@ import psutil # pylint: disable=3rd-party-module-not-gated from salt.ext import six from salt.ext.six.moves import range, builtins # pylint: disable=import-error,redefined-builtin -try: - from pytestsalt.utils import get_unused_localhost_port # pylint: disable=unused-import -except ImportError: - from tests.integration import get_unused_localhost_port +from pytestsalt.utils import get_unused_localhost_port # Import Salt Tests Support libs -from tests.support.unit import skip, _id +from tests.support.unit import skip, _id, SkipTest from tests.support.mock import patch from tests.support.paths import FILES, TMP @@ -198,10 +196,28 @@ def test_sometimes_works(self): def wrap(cls): for attempt in range(0, attempts): try: + if attempt > 0: + # Run through setUp again + # We only run it after the first iteration(>0) because the regular + # test runner will have already ran setUp the first time + setup = getattr(cls, 'setUp', None) + if callable(setup): + setup() return caller(cls) except Exception as exc: + exc_info = sys.exc_info() + if isinstance(exc, SkipTest): + six.reraise(*exc_info) + if not isinstance(exc, AssertionError) and log.isEnabledFor(logging.DEBUG): + log.exception(exc, exc_info=exc_info) if attempt >= attempts -1: - raise exc + # We won't try to run tearDown once the attempts are exhausted + # because the regular test runner will do that for us + six.reraise(*exc_info) + # Run through tearDown again + teardown = getattr(cls, 'tearDown', None) + if callable(teardown): + teardown() backoff_time = attempt ** 2 log.info( 'Found Exception. Waiting %s seconds to retry.', @@ -1058,21 +1074,10 @@ def requires_system_grains(func): @functools.wraps(func) def decorator(*args, **kwargs): if not hasattr(requires_system_grains, '__grains__'): - import salt.config - root_dir = tempfile.mkdtemp(dir=TMP) - defaults = salt.config.DEFAULT_MINION_OPTS.copy() - defaults.pop('conf_file') - defaults.update({ - 'root_dir': root_dir, - 'cachedir': 'cachedir', - 'sock_dir': 'sock', - 'pki_dir': 'pki', - 'log_file': 'logs/minion', - 'pidfile': 'pids/minion.pid' - }) - opts = salt.config.minion_config(None, defaults=defaults) + # Late import + from tests.support.sminion import build_minion_opts + opts = build_minion_opts(minion_id='runtests-internal-sminion') requires_system_grains.__grains__ = salt.loader.grains(opts) - shutil.rmtree(root_dir, ignore_errors=True) kwargs['grains'] = requires_system_grains.__grains__ return func(*args, **kwargs) return decorator @@ -1084,6 +1089,38 @@ def requires_salt_modules(*names): .. versionadded:: 0.5.2 ''' + + def _check_required_salt_modules(*required_salt_modules): + # Late import + from tests.support.sminion import create_sminion + required_salt_modules = set(required_salt_modules) + sminion = create_sminion(minion_id='runtests-internal-sminion') + available_modules = list(sminion.functions) + not_available_modules = set() + try: + cached_not_available_modules = sminion.__not_availiable_modules__ + except AttributeError: + cached_not_available_modules = sminion.__not_availiable_modules__ = set() + + if cached_not_available_modules: + for not_available_module in cached_not_available_modules: + if not_available_module in required_salt_modules: + not_available_modules.add(not_available_module) + required_salt_modules.remove(not_available_module) + + for required_module_name in required_salt_modules: + search_name = required_module_name + if '.' not in search_name: + search_name += '.*' + if not fnmatch.filter(available_modules, search_name): + not_available_modules.add(required_module_name) + cached_not_available_modules.add(required_module_name) + + if not_available_modules: + if len(not_available_modules) == 1: + raise SkipTest('Salt module \'{}\' is not available'.format(*not_available_modules)) + raise SkipTest('Salt modules not available: {}'.format(', '.join(not_available_modules))) + def decorator(caller): if inspect.isclass(caller): @@ -1091,67 +1128,19 @@ def decorator(caller): old_setup = getattr(caller, 'setUp', None) def setUp(self, *args, **kwargs): + _check_required_salt_modules(*names) if old_setup is not None: old_setup(self, *args, **kwargs) - if not hasattr(self, 'run_function'): - raise RuntimeError( - '{0} does not have the \'run_function\' method which ' - 'is necessary to collect the loaded modules'.format( - self.__class__.__name__ - ) - ) - - if not hasattr(requires_salt_modules, '__available_modules__'): - requires_salt_modules.__available_modules__ = set() - - _names = [] - for name in names: - if name not in requires_salt_modules.__available_modules__: - _names.append(name) - - if _names: - not_found_modules = self.run_function('runtests_helpers.modules_available', _names) - for name in _names: - if name not in not_found_modules: - requires_salt_modules.__available_modules__.add(name) - if not_found_modules: - if len(not_found_modules) == 1: - self.skipTest('Salt module {0!r} is not available'.format(not_found_modules[0])) - self.skipTest('Salt modules not available: {0!r}'.format(not_found_modules)) caller.setUp = setUp return caller # We're simply decorating functions @functools.wraps(caller) def wrapper(cls): - - if not hasattr(cls, 'run_function'): - raise RuntimeError( - '{0} does not have the \'run_function\' method which is ' - 'necessary to collect the loaded modules'.format( - cls.__class__.__name__ - ) - ) - - if not hasattr(requires_salt_modules, '__available_modules__'): - requires_salt_modules.__available_modules__ = set() - - _names = [] - for name in names: - if name not in requires_salt_modules.__available_modules__: - _names.append(name) - - if _names: - not_found_modules = cls.run_function('runtests_helpers.modules_available', _names) - for name in _names: - if name not in not_found_modules: - requires_salt_modules.__available_modules__.add(name) - if not_found_modules: - if len(not_found_modules) == 1: - cls.skipTest('Salt module {0!r} is not available'.format(not_found_modules[0])) - cls.skipTest('Salt modules not available: {0!r}'.format(not_found_modules)) + _check_required_salt_modules(*names) return caller(cls) + return wrapper return decorator diff --git a/tests/support/parser/__init__.py b/tests/support/parser/__init__.py index 2802b20c6250..5e3af5e7737d 100644 --- a/tests/support/parser/__init__.py +++ b/tests/support/parser/__init__.py @@ -72,7 +72,7 @@ def __global_logging_exception_handler(exc_type, exc_value, exc_traceback, # Log the exception try: msg = ( - 'An un-handled exception was caught by salt-testing\'s global exception handler:\n{}: {}\n{}'.format( + 'An un-handled exception was caught by salt\'s testing global exception handler:\n{}: {}\n{}'.format( exc_type.__name__, exc_value, ''.join(_format_exception(exc_type, exc_value, exc_traceback)).strip() @@ -402,7 +402,7 @@ def _test_mods(self): try: return self.__test_mods except AttributeError: - self.__test_mods = set(tests.support.paths.test_mods()) + self.__test_mods = set(tests.support.paths.list_test_mods()) return self.__test_mods def _map_files(self, files): diff --git a/tests/support/paths.py b/tests/support/paths.py index e676885692bf..ab2ec7ae2371 100644 --- a/tests/support/paths.py +++ b/tests/support/paths.py @@ -55,6 +55,7 @@ os.environ.get('TMPDIR', tempfile.gettempdir()) if not sys.platform.startswith('darwin') else '/tmp' )) TMP = os.path.join(SYS_TMP_DIR, 'salt-tests-tmpdir') +TMP_ROOT_DIR = os.path.join(TMP, 'rootdir') FILES = os.path.join(INTEGRATION_TEST_DIR, 'files') BASE_FILES = os.path.join(INTEGRATION_TEST_DIR, 'files', 'file', 'base') PROD_FILES = os.path.join(INTEGRATION_TEST_DIR, 'files', 'file', 'prod') @@ -125,7 +126,7 @@ } -def test_mods(): +def list_test_mods(): ''' A generator which returns all of the test files ''' diff --git a/tests/support/processes.py b/tests/support/processes.py index 7da2cb304e0f..3031f126aa9c 100644 --- a/tests/support/processes.py +++ b/tests/support/processes.py @@ -182,12 +182,11 @@ def stop_daemon(): log.info('[%s] pytest %s(%s) stopped', daemon_log_prefix, daemon_name, daemon_id) # request.addfinalizer(stop_daemon) - return process + break else: terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) continue - else: # pylint: disable=useless-else-on-loop - # Wrong, we have a return, its not useless + else: if process is not None: terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) raise fail_method( @@ -197,3 +196,4 @@ def stop_daemon(): attempts-1 ) ) + return process diff --git a/tests/support/runtests.py b/tests/support/runtests.py index 074db7aa091f..dc61917c9a1c 100644 --- a/tests/support/runtests.py +++ b/tests/support/runtests.py @@ -51,9 +51,6 @@ import os import shutil import logging -import multiprocessing - -import salt.utils.json # Import tests support libs import tests.support.paths as paths @@ -61,49 +58,6 @@ # Import 3rd-party libs from salt.ext import six -try: - import coverage # pylint: disable=import-error - HAS_COVERAGE = True -except ImportError: - HAS_COVERAGE = False - -try: - import multiprocessing.util - # Force forked multiprocessing processes to be measured as well - - def multiprocessing_stop(coverage_object): - ''' - Save the multiprocessing process coverage object - ''' - coverage_object.stop() - coverage_object.save() - - def multiprocessing_start(obj): - coverage_options = salt.utils.json.loads(os.environ.get('SALT_RUNTESTS_COVERAGE_OPTIONS', '{}')) - if not coverage_options: - return - - if coverage_options.get('data_suffix', False) is False: - return - - coverage_object = coverage.coverage(**coverage_options) - coverage_object.start() - - multiprocessing.util.Finalize( - None, - multiprocessing_stop, - args=(coverage_object,), - exitpriority=1000 - ) - - if HAS_COVERAGE: - multiprocessing.util.register_after_fork( - multiprocessing_start, - multiprocessing_start - ) -except ImportError: - pass - RUNNING_TESTS_USER = tests.support.helpers.this_user() @@ -132,20 +86,20 @@ def recursive_copytree(source, destination, overwrite=False): src_path = os.path.join(root, item) dst_path = os.path.join(destination, src_path.replace(source, '').lstrip(os.sep)) if not os.path.exists(dst_path): - log.debug('Creating directory: {0}'.format(dst_path)) + log.debug('Creating directory: %s', dst_path) os.makedirs(dst_path) for item in files: src_path = os.path.join(root, item) dst_path = os.path.join(destination, src_path.replace(source, '').lstrip(os.sep)) if os.path.exists(dst_path) and not overwrite: if os.stat(src_path).st_mtime > os.stat(dst_path).st_mtime: - log.debug('Copying {0} to {1}'.format(src_path, dst_path)) + log.debug('Copying %s to %s', src_path, dst_path) shutil.copy2(src_path, dst_path) else: if not os.path.isdir(os.path.dirname(dst_path)): - log.debug('Creating directory: {0}'.format(os.path.dirname(dst_path))) + log.debug('Creating directory: %s', os.path.dirname(dst_path)) os.makedirs(os.path.dirname(dst_path)) - log.debug('Copying {0} to {1}'.format(src_path, dst_path)) + log.debug('Copying %s to %s', src_path, dst_path) shutil.copy2(src_path, dst_path) @@ -204,6 +158,7 @@ def __setattr__(self, name, value): PILLAR_DIR=paths.PILLAR_DIR, ENGINES_DIR=paths.ENGINES_DIR, LOG_HANDLERS_DIR=paths.LOG_HANDLERS_DIR, + TMP_ROOT_DIR=paths.TMP_ROOT_DIR, TMP_CONF_DIR=paths.TMP_CONF_DIR, TMP_CONF_MASTER_INCLUDES=os.path.join(paths.TMP_CONF_DIR, 'master.d'), TMP_CONF_MINION_INCLUDES=os.path.join(paths.TMP_CONF_DIR, 'minion.d'), diff --git a/tests/support/sminion.py b/tests/support/sminion.py new file mode 100644 index 000000000000..0f3aab400e09 --- /dev/null +++ b/tests/support/sminion.py @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- +''' +tests.support.sminion +~~~~~~~~~~~~~~~~~~~~~ + +SMinion's support functions +''' +# Import python libs +from __future__ import absolute_import, print_function, unicode_literals +import os +import sys +import shutil +import hashlib +import logging + +# Import salt libs +import salt.minion +import salt.utils.stringutils + +# Import testing libs +from tests.support.runtests import RUNTIME_VARS + +log = logging.getLogger(__name__) + + +def build_minion_opts(minion_id=None, + root_dir=None, + initial_conf_file=None, + minion_opts_overrides=None, + skip_cached_opts=False, + cache_opts=True, + minion_role=None): + if minion_id is None: + minion_id = 'pytest-internal-sminion' + if skip_cached_opts is False: + try: + opts_cache = build_minion_opts.__cached_opts__ + except AttributeError: + opts_cache = build_minion_opts.__cached_opts__ = {} + cached_opts = opts_cache.get(minion_id) + if cached_opts: + return cached_opts + + log.info('Generating testing minion %r configuration...', minion_id) + if root_dir is None: + hashed_minion_id = hashlib.sha1() + hashed_minion_id.update(salt.utils.stringutils.to_bytes(minion_id)) + root_dir = os.path.join(RUNTIME_VARS.TMP_ROOT_DIR, hashed_minion_id.hexdigest()[:6]) + + if initial_conf_file is not None: + minion_opts = salt.config._read_conf_file(initial_conf_file) # pylint: disable=protected-access + else: + minion_opts = {} + + conf_dir = os.path.join(root_dir, 'conf') + conf_file = os.path.join(conf_dir, 'minion') + + minion_opts['id'] = minion_id + minion_opts['conf_file'] = conf_file + minion_opts['root_dir'] = root_dir + minion_opts['cachedir'] = 'cache' + minion_opts['user'] = RUNTIME_VARS.RUNNING_TESTS_USER + minion_opts['pki_dir'] = 'pki' + minion_opts['hosts.file'] = os.path.join(RUNTIME_VARS.TMP_ROOT_DIR, 'hosts') + minion_opts['aliases.file'] = os.path.join(RUNTIME_VARS.TMP_ROOT_DIR, 'aliases') + minion_opts['file_client'] = 'local' + minion_opts['server_id_use_crc'] = 'adler32' + minion_opts['pillar_roots'] = { + 'base': [ + RUNTIME_VARS.TMP_PILLAR_TREE, + ] + } + minion_opts['file_roots'] = { + 'base': [ + # Let's support runtime created files that can be used like: + # salt://my-temp-file.txt + RUNTIME_VARS.TMP_STATE_TREE + ], + # Alternate root to test __env__ choices + 'prod': [ + os.path.join(RUNTIME_VARS.FILES, 'file', 'prod'), + RUNTIME_VARS.TMP_PRODENV_STATE_TREE + ] + } + if initial_conf_file and initial_conf_file.startswith(RUNTIME_VARS.FILES): + # We assume we were passed a minion configuration file defined fo testing and, as such + # we define the file and pillar roots to include the testing states/pillar trees + minion_opts['pillar_roots']['base'].append( + os.path.join(RUNTIME_VARS.FILES, 'pillar', 'base'), + ) + minion_opts['file_roots']['base'].append( + os.path.join(RUNTIME_VARS.FILES, 'file', 'base'), + ) + minion_opts['file_roots']['prod'].append( + os.path.join(RUNTIME_VARS.FILES, 'file', 'prod'), + ) + + # We need to copy the extension modules into the new master root_dir or + # it will be prefixed by it + extension_modules_path = os.path.join(root_dir, 'extension_modules') + if not os.path.exists(extension_modules_path): + shutil.copytree( + os.path.join( + RUNTIME_VARS.FILES, 'extension_modules' + ), + extension_modules_path + ) + minion_opts['extension_modules'] = extension_modules_path + + # Custom grains + if 'grains' not in minion_opts: + minion_opts['grains'] = {} + if minion_role is not None: + minion_opts['grains']['role'] = minion_role + + # Under windows we can't seem to properly create a virtualenv off of another + # virtualenv, we can on linux but we will still point to the virtualenv binary + # outside the virtualenv running the test suite, if that's the case. + try: + real_prefix = sys.real_prefix + # The above attribute exists, this is a virtualenv + if salt.utils.platform.is_windows(): + virtualenv_binary = os.path.join(real_prefix, 'Scripts', 'virtualenv.exe') + else: + # We need to remove the virtualenv from PATH or we'll get the virtualenv binary + # from within the virtualenv, we don't want that + path = os.environ.get('PATH') + if path is not None: + path_items = path.split(os.pathsep) + for item in path_items[:]: + if item.startswith(sys.base_prefix): + path_items.remove(item) + os.environ['PATH'] = os.pathsep.join(path_items) + virtualenv_binary = salt.utils.which('virtualenv') + if path is not None: + # Restore previous environ PATH + os.environ['PATH'] = path + if not virtualenv_binary.startswith(real_prefix): + virtualenv_binary = None + if virtualenv_binary and not os.path.exists(virtualenv_binary): + # It doesn't exist?! + virtualenv_binary = None + except AttributeError: + # We're not running inside a virtualenv + virtualenv_binary = None + if virtualenv_binary: + minion_opts['venv_bin'] = virtualenv_binary + + # Override minion_opts with minion_opts_overrides + if minion_opts_overrides: + minion_opts.update(minion_opts_overrides) + + if not os.path.exists(conf_dir): + os.makedirs(conf_dir) + + with salt.utils.files.fopen(conf_file, 'w') as fp_: + salt.utils.yaml.safe_dump(minion_opts, fp_, default_flow_style=False) + + log.info('Generating testing minion %r configuration completed.', minion_id) + minion_opts = salt.config.minion_config(conf_file, minion_id=minion_id, cache_minion_id=True) + salt.utils.verify.verify_env( + [ + os.path.join(minion_opts['pki_dir'], 'accepted'), + os.path.join(minion_opts['pki_dir'], 'rejected'), + os.path.join(minion_opts['pki_dir'], 'pending'), + os.path.dirname(minion_opts['log_file']), + minion_opts['extension_modules'], + minion_opts['cachedir'], + minion_opts['sock_dir'], + RUNTIME_VARS.TMP_STATE_TREE, + RUNTIME_VARS.TMP_PILLAR_TREE, + RUNTIME_VARS.TMP_PRODENV_STATE_TREE, + RUNTIME_VARS.TMP, + ], + RUNTIME_VARS.RUNNING_TESTS_USER, + root_dir=root_dir + ) + if cache_opts: + try: + opts_cache = build_minion_opts.__cached_opts__ + except AttributeError: + opts_cache = build_minion_opts.__cached_opts__ = {} + opts_cache[minion_id] = minion_opts + return minion_opts + + +def create_sminion(minion_id=None, + root_dir=None, + initial_conf_file=None, + sminion_cls=salt.minion.SMinion, + minion_opts_overrides=None, + skip_cached_minion=False, + cache_sminion=True): + if minion_id is None: + minion_id = 'pytest-internal-sminion' + if skip_cached_minion is False: + try: + minions_cache = create_sminion.__cached_minions__ + except AttributeError: + create_sminion.__cached_minions__ = {} + cached_minion = create_sminion.__cached_minions__.get(minion_id) + if cached_minion: + return cached_minion + minion_opts = build_minion_opts(minion_id=minion_id, + root_dir=root_dir, + initial_conf_file=initial_conf_file, + minion_opts_overrides=minion_opts_overrides, + skip_cached_opts=skip_cached_minion, + cache_opts=cache_sminion) + log.info('Instantiating a testing %s(%s)', sminion_cls.__name__, minion_id) + sminion = sminion_cls(minion_opts) + if cache_sminion: + try: + minions_cache = create_sminion.__cached_minions__ + except AttributeError: + minions_cache = create_sminion.__cached_minions__ = {} + minions_cache[minion_id] = sminion + return sminion diff --git a/tests/support/zfs.py b/tests/support/zfs.py new file mode 100644 index 000000000000..5b260ff82faf --- /dev/null +++ b/tests/support/zfs.py @@ -0,0 +1,870 @@ +# -*- coding: utf-8 -*- +''' + tests.support.zfs + ~~~~~~~~~~~~~~~~~ + + ZFS related unit test data structures +''' + +# Import Python libs +from __future__ import absolute_import, unicode_literals, print_function + +# Import salt libs +import salt.utils.zfs + +# Import Salt tests libs +from tests.support.mock import MagicMock, patch + + +class ZFSMockData(object): + + def __init__(self): + # property_map mocks + self.pmap_exec_zpool = { + 'retcode': 2, + 'stdout': '', + 'stderr': "\n".join([ + 'missing property argument', + 'usage:', + ' get [-Hp] [-o "all" | field[,...]] <"all" | property[,...]> ...', + '', + 'the following properties are supported:', + '', + ' PROPERTY EDIT VALUES', + '', + ' allocated NO ', + ' capacity NO ', + ' dedupratio NO <1.00x or higher if deduped>', + ' expandsize NO ', + ' fragmentation NO ', + ' free NO ', + ' freeing NO ', + ' guid NO ', + ' health NO ', + ' leaked NO ', + ' size NO ', + ' altroot YES ', + ' autoexpand YES on | off', + ' autoreplace YES on | off', + ' bootfs YES ', + ' bootsize YES ', + ' cachefile YES | none', + ' comment YES ', + ' dedupditto YES ', + ' delegation YES on | off', + ' failmode YES wait | continue | panic', + ' listsnapshots YES on | off', + ' readonly YES on | off', + ' version YES ', + ' feature@... YES disabled | enabled | active', + '', + 'The feature@ properties must be appended with a feature name.', + 'See zpool-features(5). ', + ]), + } + self.pmap_zpool = { + 'comment': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'freeing': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'listsnapshots': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'leaked': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'version': { + 'edit': True, + 'type': 'numeric', + 'values': '' + }, + 'write': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'replace': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'delegation': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'dedupditto': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'autoexpand': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'alloc': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'allocated': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'guid': { + 'edit': False, + 'type': 'numeric', + 'values': '' + }, + 'size': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'cap': { + 'edit': False, + 'type': 'numeric', + 'values': '' + }, + 'capacity': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + "capacity-alloc": { + "edit": False, + "type": "size", + "values": "" + }, + "capacity-free": { + "edit": False, + "type": "size", + "values": "" + }, + 'cachefile': { + 'edit': True, + 'type': 'str', + 'values': ' | none' + }, + "cksum": { + "edit": False, + "type": "numeric", + "values": "" + }, + 'bootfs': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'autoreplace': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + "bandwith-read": { + "edit": False, + "type": "size", + "values": "" + }, + "bandwith-write": { + "edit": False, + "type": "size", + "values": "" + }, + "operations-read": { + "edit": False, + "type": "size", + "values": "" + }, + "operations-write": { + "edit": False, + "type": "size", + "values": "" + }, + "read": { + "edit": False, + "type": "size", + "values": "" + }, + 'readonly': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'dedupratio': { + 'edit': False, + 'type': 'str', + 'values': '<1.00x or higher if deduped>' + }, + 'health': { + 'edit': False, + 'type': 'str', + 'values': '' + }, + 'feature@': { + 'edit': True, + 'type': 'str', + 'values': 'disabled | enabled | active' + }, + 'expandsize': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'listsnaps': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'bootsize': { + 'edit': True, + 'type': 'size', + 'values': '' + }, + 'free': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'failmode': { + 'edit': True, + 'type': 'str', + 'values': 'wait | continue | panic' + }, + 'altroot': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'expand': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'frag': { + 'edit': False, + 'type': 'str', + 'values': '' + }, + 'fragmentation': { + 'edit': False, + 'type': 'str', + 'values': '' + } + } + self.pmap_exec_zfs = { + 'retcode': 2, + 'stdout': '', + 'stderr': "\n".join([ + 'missing property argument', + 'usage:', + ' get [-crHp] [-d max] [-o "all" | field[,...]]', + ' [-t type[,...]] [-s source[,...]]', + ' <"all" | property[,...]> [filesystem|volume|snapshot|bookmark] ...', + '', + 'The following properties are supported:', + '', + ' PROPERTY EDIT INHERIT VALUES', + '', + ' available NO NO ', + ' clones NO NO [,...]', + ' compressratio NO NO <1.00x or higher if compressed>', + ' creation NO NO ', + ' defer_destroy NO NO yes | no', + ' filesystem_count NO NO ', + ' logicalreferenced NO NO ', + ' logicalused NO NO ', + ' mounted NO NO yes | no', + ' origin NO NO ', + ' receive_resume_token NO NO ', + ' refcompressratio NO NO <1.00x or higher if compressed>', + ' referenced NO NO ', + ' snapshot_count NO NO ', + ' type NO NO filesystem | volume | snapshot | bookmark', + ' used NO NO ', + ' usedbychildren NO NO ', + ' usedbydataset NO NO ', + ' usedbyrefreservation NO NO ', + ' usedbysnapshots NO NO ', + ' userrefs NO NO ', + ' written NO NO ', + ' aclinherit YES YES discard | noallow | restricted | passthrough | passthrough-x', + ' aclmode YES YES discard | groupmask | passthrough | restricted', + ' atime YES YES on | off', + ' canmount YES NO on | off | noauto', + ' casesensitivity NO YES sensitive | insensitive | mixed', + ' checksum YES YES on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr', + ' compression YES YES on | off | lzjb | gzip | gzip-[1-9] | zle | lz4', + ' copies YES YES 1 | 2 | 3', + ' dedup YES YES on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify', + ' devices YES YES on | off', + ' exec YES YES on | off', + ' filesystem_limit YES NO | none', + ' logbias YES YES latency | throughput', + ' mlslabel YES YES ', + ' mountpoint YES YES | legacy | none', + ' nbmand YES YES on | off', + ' normalization NO YES none | formC | formD | formKC | formKD', + ' primarycache YES YES all | none | metadata', + ' quota YES NO | none', + ' readonly YES YES on | off', + ' recordsize YES YES 512 to 1M, power of 2', + ' redundant_metadata YES YES all | most', + ' refquota YES NO | none', + ' refreservation YES NO | none', + ' reservation YES NO | none', + ' secondarycache YES YES all | none | metadata', + ' setuid YES YES on | off', + ' sharenfs YES YES on | off | share(1M) options', + ' sharesmb YES YES on | off | sharemgr(1M) options', + ' snapdir YES YES hidden | visible', + ' snapshot_limit YES NO | none', + ' sync YES YES standard | always | disabled', + ' utf8only NO YES on | off', + ' version YES NO 1 | 2 | 3 | 4 | 5 | current', + ' volblocksize NO YES 512 to 128k, power of 2', + ' volsize YES NO ', + ' vscan YES YES on | off', + ' xattr YES YES on | off', + ' zoned YES YES on | off', + ' userused@... NO NO ', + ' groupused@... NO NO ', + ' userquota@... YES NO | none', + ' groupquota@... YES NO | none', + ' written@ NO NO ', + '', + 'Sizes are specified in bytes with standard units such as K, M, G, etc.', + '', + 'User-defined properties can be specified by using a name containing a colon (:).', + '', + 'The {user|group}{used|quota}@ properties must be appended with', + 'a user or group specifier of one of these forms:', + ' POSIX name (eg: "matt")', + ' POSIX id (eg: "126829")', + ' SMB name@domain (eg: "matt@sun")', + ' SMB SID (eg: "S-1-234-567-89")', + ]), + } + self.pmap_zfs = { + "origin": { + "edit": False, + "inherit": False, + "values": "", + "type": "str" + }, + "setuid": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "referenced": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "vscan": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "logicalused": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "userrefs": { + "edit": False, + "inherit": False, + "values": "", + "type": "numeric" + }, + "primarycache": { + "edit": True, + "inherit": True, + "values": "all | none | metadata", + "type": "str" + }, + "logbias": { + "edit": True, + "inherit": True, + "values": "latency | throughput", + "type": "str" + }, + "creation": { + "edit": False, + "inherit": False, + "values": "", + "type": "str" + }, + "sync": { + "edit": True, + "inherit": True, + "values": "standard | always | disabled", + "type": "str" + }, + "dedup": { + "edit": True, + "inherit": True, + "values": "on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify", + "type": "bool" + }, + "sharenfs": { + "edit": True, + "inherit": True, + "values": "on | off | share(1m) options", + "type": "bool" + }, + "receive_resume_token": { + "edit": False, + "inherit": False, + "values": "", + "type": "str" + }, + "usedbyrefreservation": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "sharesmb": { + "edit": True, + "inherit": True, + "values": "on | off | sharemgr(1m) options", + "type": "bool" + }, + "rdonly": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "reservation": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "reserv": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "mountpoint": { + "edit": True, + "inherit": True, + "values": " | legacy | none", + "type": "str" + }, + "casesensitivity": { + "edit": False, + "inherit": True, + "values": "sensitive | insensitive | mixed", + "type": "str" + }, + "utf8only": { + "edit": False, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "usedbysnapshots": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "readonly": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "written@": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "avail": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "recsize": { + "edit": True, + "inherit": True, + "values": "512 to 1m, power of 2", + "type": "str" + }, + "atime": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "compression": { + "edit": True, + "inherit": True, + "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", + "type": "bool" + }, + "snapdir": { + "edit": True, + "inherit": True, + "values": "hidden | visible", + "type": "str" + }, + "aclmode": { + "edit": True, + "inherit": True, + "values": "discard | groupmask | passthrough | restricted", + "type": "str" + }, + "zoned": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "copies": { + "edit": True, + "inherit": True, + "values": "1 | 2 | 3", + "type": "numeric" + }, + "snapshot_limit": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "numeric" + }, + "aclinherit": { + "edit": True, + "inherit": True, + "values": "discard | noallow | restricted | passthrough | passthrough-x", + "type": "str" + }, + "compressratio": { + "edit": False, + "inherit": False, + "values": "<1.00x or higher if compressed>", + "type": "str" + }, + "xattr": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "written": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "version": { + "edit": True, + "inherit": False, + "values": "1 | 2 | 3 | 4 | 5 | current", + "type": "numeric" + }, + "recordsize": { + "edit": True, + "inherit": True, + "values": "512 to 1m, power of 2", + "type": "str" + }, + "refquota": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "filesystem_limit": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "numeric" + }, + "lrefer.": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "type": { + "edit": False, + "inherit": False, + "values": "filesystem | volume | snapshot | bookmark", + "type": "str" + }, + "secondarycache": { + "edit": True, + "inherit": True, + "values": "all | none | metadata", + "type": "str" + }, + "refer": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "available": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "used": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "exec": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "compress": { + "edit": True, + "inherit": True, + "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", + "type": "bool" + }, + "volblock": { + "edit": False, + "inherit": True, + "values": "512 to 128k, power of 2", + "type": "str" + }, + "refcompressratio": { + "edit": False, + "inherit": False, + "values": "<1.00x or higher if compressed>", + "type": "str" + }, + "quota": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "groupquota@": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "userquota@": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "snapshot_count": { + "edit": False, + "inherit": False, + "values": "", + "type": "numeric" + }, + "volsize": { + "edit": True, + "inherit": False, + "values": "", + "type": "size" + }, + "clones": { + "edit": False, + "inherit": False, + "values": "[,...]", + "type": "str" + }, + "canmount": { + "edit": True, + "inherit": False, + "values": "on | off | noauto", + "type": "bool" + }, + "mounted": { + "edit": False, + "inherit": False, + "values": "yes | no", + "type": "bool_alt" + }, + "groupused@": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "normalization": { + "edit": False, + "inherit": True, + "values": "none | formc | formd | formkc | formkd", + "type": "str" + }, + "usedbychildren": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "usedbydataset": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "mlslabel": { + "edit": True, + "inherit": True, + "values": "", + "type": "str" + }, + "refreserv": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "defer_destroy": { + "edit": False, + "inherit": False, + "values": "yes | no", + "type": "bool_alt" + }, + "volblocksize": { + "edit": False, + "inherit": True, + "values": "512 to 128k, power of 2", + "type": "str" + }, + "lused.": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "redundant_metadata": { + "edit": True, + "inherit": True, + "values": "all | most", + "type": "str" + }, + "filesystem_count": { + "edit": False, + "inherit": False, + "values": "", + "type": "numeric" + }, + "devices": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "refreservation": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "userused@": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "logicalreferenced": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "checksum": { + "edit": True, + "inherit": True, + "values": "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr", + "type": "bool" + }, + "nbmand": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + } + } + + def _from_auto(self, name, value, source='auto'): + ''' + some more complex patching for zfs.from_auto + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.from_auto(name, value, source) + + def _from_auto_dict(self, values, source='auto'): + ''' + some more complex patching for zfs.from_auto_dict + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.from_auto_dict(values, source) + + def _to_auto(self, name, value, source='auto', convert_to_human=True): + ''' + some more complex patching for zfs.to_auto + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.to_auto(name, value, source, convert_to_human) + + def _to_auto_dict(self, values, source='auto', convert_to_human=True): + ''' + some more complex patching for zfs.to_auto_dict + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.to_auto_dict(values, source, convert_to_human) + + def get_patched_utils(self): + return { + 'zfs.is_supported': MagicMock(return_value=True), + 'zfs.has_feature_flags': MagicMock(return_value=True), + 'zfs.property_data_zpool': MagicMock(return_value=self.pmap_zpool), + 'zfs.property_data_zfs': MagicMock(return_value=self.pmap_zfs), + # NOTE: we make zpool_command and zfs_command a NOOP + # these are extensively tested in tests.unit.utils.test_zfs + 'zfs.zpool_command': MagicMock(return_value='/bin/false'), + 'zfs.zfs_command': MagicMock(return_value='/bin/false'), + # NOTE: from_auto_dict is a special snowflake + # internally it calls multiple calls from + # salt.utils.zfs but we cannot patch those using + # the common methode, __utils__ is not available + # so they are direct calls, we do some voodoo here. + 'zfs.from_auto_dict': self._from_auto_dict, + 'zfs.from_auto': self._from_auto, + 'zfs.to_auto_dict': self._to_auto_dict, + 'zfs.to_auto': self._to_auto, + } diff --git a/tests/unit/beacons/test_inotify.py b/tests/unit/beacons/test_inotify.py index 5c0dc8c89868..41b6f8475764 100644 --- a/tests/unit/beacons/test_inotify.py +++ b/tests/unit/beacons/test_inotify.py @@ -39,10 +39,33 @@ def setUp(self): def tearDown(self): shutil.rmtree(self.tmpdir, ignore_errors=True) + def test_non_list_config(self): + config = {} + + ret = inotify.validate(config) + + self.assertEqual(ret, (False, 'Configuration for inotify beacon must' + ' be a list.')) + def test_empty_config(self): config = [{}] - ret = inotify.beacon(config) - self.assertEqual(ret, []) + ret = inotify.validate(config) + _expected = (False, 'Configuration for inotify beacon must include files.') + self.assertEqual(ret, _expected) + + def test_files_none_config(self): + config = [{'files': None}] + ret = inotify.validate(config) + _expected = (False, 'Configuration for inotify beacon invalid, ' + 'files must be a dict.') + self.assertEqual(ret, _expected) + + def test_files_list_config(self): + config = [{'files': [{u'/importantfile': {u'mask': [u'modify']}}]}] + ret = inotify.validate(config) + _expected = (False, 'Configuration for inotify beacon invalid, ' + 'files must be a dict.') + self.assertEqual(ret, _expected) def test_file_open(self): path = os.path.realpath(__file__) diff --git a/tests/unit/beacons/test_status.py b/tests/unit/beacons/test_status.py index 32fa0af1b370..175716ffcade 100644 --- a/tests/unit/beacons/test_status.py +++ b/tests/unit/beacons/test_status.py @@ -30,7 +30,7 @@ class StatusBeaconTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): - opts = salt.config.DEFAULT_MINION_OPTS + opts = salt.config.DEFAULT_MINION_OPTS.copy() opts['grains'] = salt.loader.grains(opts) module_globals = { '__opts__': opts, diff --git a/tests/unit/beacons/test_watchdog.py b/tests/unit/beacons/test_watchdog.py index b96a81ccf7bc..ffaa2d6d2930 100644 --- a/tests/unit/beacons/test_watchdog.py +++ b/tests/unit/beacons/test_watchdog.py @@ -9,6 +9,7 @@ # Salt libs import salt.utils.files +import salt.utils.platform from salt.beacons import watchdog from salt.ext.six.moves import range @@ -40,6 +41,7 @@ def create(path, content=None): @skipIf(not watchdog.HAS_WATCHDOG, 'watchdog is not available') +@skipIf(salt.utils.platform.is_darwin(), 'Tests were being skipped pre macos under nox. Keep it like that for now.') class IWatchdogBeaconTestCase(TestCase, LoaderModuleMockMixin): ''' Test case for salt.beacons.watchdog diff --git a/tests/unit/engines/test_slack.py b/tests/unit/engines/test_slack.py index 2b8e0d7272ef..ef228a8fa6f1 100644 --- a/tests/unit/engines/test_slack.py +++ b/tests/unit/engines/test_slack.py @@ -30,7 +30,7 @@ def setup_loader_modules(self): return {slack: {}} def setUp(self): - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() token = 'xoxb-xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx' with patch.dict(slack.__opts__, mock_opts): diff --git a/tests/unit/fileserver/test_roots.py b/tests/unit/fileserver/test_roots.py index 2c3e6f2d8c0b..1044e7bfbae5 100644 --- a/tests/unit/fileserver/test_roots.py +++ b/tests/unit/fileserver/test_roots.py @@ -10,8 +10,7 @@ import tempfile # Import Salt Testing libs -from tests.integration import AdaptedConfigurationTestCaseMixin -from tests.support.mixins import LoaderModuleMockMixin +from tests.support.mixins import AdaptedConfigurationTestCaseMixin, LoaderModuleMockMixin from tests.support.paths import BASE_FILES, TMP, TMP_STATE_TREE from tests.support.unit import TestCase, skipIf from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON diff --git a/tests/unit/modules/test_boto_apigateway.py b/tests/unit/modules/test_boto_apigateway.py index be26b3f093db..0f88f1d9b22f 100644 --- a/tests/unit/modules/test_boto_apigateway.py +++ b/tests/unit/modules/test_boto_apigateway.py @@ -173,7 +173,7 @@ class BotoApiGatewayTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform']) diff --git a/tests/unit/modules/test_boto_cloudtrail.py b/tests/unit/modules/test_boto_cloudtrail.py index b01ed59de20a..2f06476c8290 100644 --- a/tests/unit/modules/test_boto_cloudtrail.py +++ b/tests/unit/modules/test_boto_cloudtrail.py @@ -102,7 +102,7 @@ class BotoCloudTrailTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_cloudwatch_event.py b/tests/unit/modules/test_boto_cloudwatch_event.py index 6057331e38e2..f016fc5617c6 100644 --- a/tests/unit/modules/test_boto_cloudwatch_event.py +++ b/tests/unit/modules/test_boto_cloudwatch_event.py @@ -91,7 +91,7 @@ class BotoCloudWatchEventTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_cognitoidentity.py b/tests/unit/modules/test_boto_cognitoidentity.py index 0030b68be1ef..bde2ae2da79c 100644 --- a/tests/unit/modules/test_boto_cognitoidentity.py +++ b/tests/unit/modules/test_boto_cognitoidentity.py @@ -116,7 +116,7 @@ class BotoCognitoIdentityTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_elasticsearch_domain.py b/tests/unit/modules/test_boto_elasticsearch_domain.py index e39487ac30d0..1fa1e7ba7c42 100644 --- a/tests/unit/modules/test_boto_elasticsearch_domain.py +++ b/tests/unit/modules/test_boto_elasticsearch_domain.py @@ -88,7 +88,7 @@ class BotoElasticsearchDomainTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = salt.config.DEFAULT_MINION_OPTS + self.opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( self.opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_elb.py b/tests/unit/modules/test_boto_elb.py index 9da5c74c33b3..e8ec1070e444 100644 --- a/tests/unit/modules/test_boto_elb.py +++ b/tests/unit/modules/test_boto_elb.py @@ -104,7 +104,7 @@ class BotoElbTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): - opts = salt.config.DEFAULT_MASTER_OPTS + opts = salt.config.DEFAULT_MASTER_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto', 'args', 'systemd', 'path', 'platform']) diff --git a/tests/unit/modules/test_boto_iot.py b/tests/unit/modules/test_boto_iot.py index 4475a93d41ee..4d2025d6381e 100644 --- a/tests/unit/modules/test_boto_iot.py +++ b/tests/unit/modules/test_boto_iot.py @@ -127,7 +127,7 @@ class BotoIoTTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_lambda.py b/tests/unit/modules/test_boto_lambda.py index aeb9ae09d41c..cf3f6a6c3b98 100644 --- a/tests/unit/modules/test_boto_lambda.py +++ b/tests/unit/modules/test_boto_lambda.py @@ -122,7 +122,7 @@ class BotoLambdaTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_route53.py b/tests/unit/modules/test_boto_route53.py index b36c4cb31666..ed43c12b2168 100644 --- a/tests/unit/modules/test_boto_route53.py +++ b/tests/unit/modules/test_boto_route53.py @@ -76,7 +76,7 @@ class BotoRoute53TestCase(TestCase, LoaderModuleMockMixin): TestCase for salt.modules.boto_route53 module ''' def setup_loader_modules(self): - self.opts = salt.config.DEFAULT_MINION_OPTS + self.opts = salt.config.DEFAULT_MINION_OPTS.copy() self.opts['route53.keyid'] = 'GKTADJGHEIQSXMKKRBJ08H' self.opts['route53.key'] = 'askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs' utils = salt.loader.utils(self.opts) diff --git a/tests/unit/modules/test_boto_s3_bucket.py b/tests/unit/modules/test_boto_s3_bucket.py index ab3d85c5471d..54868878438c 100644 --- a/tests/unit/modules/test_boto_s3_bucket.py +++ b/tests/unit/modules/test_boto_s3_bucket.py @@ -205,7 +205,7 @@ class BotoS3BucketTestCaseBase(TestCase, LoaderModuleMockMixin): conn = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto3', 'args', 'systemd', 'path', 'platform'], diff --git a/tests/unit/modules/test_boto_secgroup.py b/tests/unit/modules/test_boto_secgroup.py index c5722737ead5..d5450c268e71 100644 --- a/tests/unit/modules/test_boto_secgroup.py +++ b/tests/unit/modules/test_boto_secgroup.py @@ -95,7 +95,7 @@ class BotoSecgroupTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): - opts = salt.config.DEFAULT_MASTER_OPTS + opts = salt.config.DEFAULT_MASTER_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto', 'args', 'systemd', 'path', 'platform']) diff --git a/tests/unit/modules/test_boto_vpc.py b/tests/unit/modules/test_boto_vpc.py index dab3e7eb5c83..1f30c1644092 100644 --- a/tests/unit/modules/test_boto_vpc.py +++ b/tests/unit/modules/test_boto_vpc.py @@ -140,7 +140,7 @@ class BotoVpcTestCaseBase(TestCase, LoaderModuleMockMixin): conn3 = None def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['boto', 'boto3', 'args', 'systemd', 'path', 'platform']) diff --git a/tests/unit/modules/test_dockermod.py b/tests/unit/modules/test_dockermod.py index 168ab3125cff..a21a8cc501ff 100644 --- a/tests/unit/modules/test_dockermod.py +++ b/tests/unit/modules/test_dockermod.py @@ -45,7 +45,7 @@ class DockerTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): utils = salt.loader.utils( - salt.config.DEFAULT_MINION_OPTS, + salt.config.DEFAULT_MINION_OPTS.copy(), whitelist=['args', 'docker', 'json', 'state', 'thin', 'systemd', 'path', 'platform'] ) diff --git a/tests/unit/modules/test_hipchat.py b/tests/unit/modules/test_hipchat.py deleted file mode 100644 index b31be8c93398..000000000000 --- a/tests/unit/modules/test_hipchat.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: utf-8 -*- -''' - :codeauthor: Jayesh Kariya -''' - -# Import Python libs -from __future__ import absolute_import, print_function, unicode_literals - -# Import Salt Testing Libs -from tests.support.mixins import LoaderModuleMockMixin -from tests.support.unit import TestCase, skipIf -from tests.support.mock import ( - MagicMock, - patch, - NO_MOCK, - NO_MOCK_REASON -) - -# Import Salt Libs -import salt.modules.hipchat as hipchat - - -@skipIf(NO_MOCK, NO_MOCK_REASON) -class HipchatTestCase(TestCase, LoaderModuleMockMixin): - ''' - Test cases for salt.modules.hipchat - ''' - def setup_loader_modules(self): - return {hipchat: {}} - - # 'list_rooms' function tests: 1 - - def test_list_rooms(self): - ''' - Test if it list all HipChat rooms. - ''' - with patch('salt.modules.hipchat._query', MagicMock(return_value=True)): - self.assertEqual(hipchat.list_rooms(), True) - - # 'list_users' function tests: 1 - - def test_list_users(self): - ''' - Test if it list all HipChat users. - ''' - with patch('salt.modules.hipchat._query', MagicMock(return_value=True)): - self.assertEqual(hipchat.list_users(), True) - - # 'find_room' function tests: 1 - - def test_find_room(self): - ''' - Test if it find a room by name and return it. - ''' - mock = MagicMock(return_value=[{'name': 'Development Room'}]) - with patch.object(hipchat, 'list_rooms', mock): - self.assertEqual(hipchat.find_room('Development Room'), - {'name': 'Development Room'}) - - self.assertEqual(hipchat.find_room('QA Room'), False) - - # 'find_user' function tests: 1 - - def test_find_user(self): - ''' - Test if it find a user by name and return it. - ''' - mock = MagicMock(return_value=[{'name': 'Thomas Hatch'}]) - with patch.object(hipchat, 'list_rooms', mock): - self.assertEqual(hipchat.find_room('Thomas Hatch'), - {'name': 'Thomas Hatch'}) - - self.assertEqual(hipchat.find_user('Salt QA'), False) - - # 'send_message' function tests: 1 - - def test_send_message(self): - ''' - Test if it send a message to a HipChat room. - ''' - with patch('salt.modules.hipchat._query', MagicMock(return_value=True)): - self.assertEqual(hipchat.send_message('Development Room', - 'Build is done', - 'Build Server'), True) - - def test_send_message_false(self): - ''' - Test if it send a message to a HipChat room. - ''' - with patch('salt.modules.hipchat._query', MagicMock(return_value=False)): - self.assertEqual(hipchat.send_message('Development Room', - 'Build is done', - 'Build Server'), False) diff --git a/tests/unit/modules/test_mdadm_raid.py b/tests/unit/modules/test_mdadm_raid.py index bfca3af8762e..c9b09ed94eb8 100644 --- a/tests/unit/modules/test_mdadm_raid.py +++ b/tests/unit/modules/test_mdadm_raid.py @@ -75,3 +75,26 @@ def test_create_test_mode(self): '--force -l 5 -e default -n 3 ' '/dev/sdb1 /dev/sdc1 /dev/sdd1'.split()), sorted(ret.split())) assert not mock.called, 'test mode failed, cmd.run called' + + def test_examine(self): + ''' + Test for mdadm_raid.examine + ''' + mock = MagicMock(return_value='ARRAY /dev/md/pool metadata=1.2 UUID=567da122:fb8e445e:55b853e0:81bd0a3e name=positron:pool') + with patch.dict(mdadm.__salt__, {'cmd.run_stdout': mock}): + self.assertEqual(mdadm.examine('/dev/md0'), + { + 'ARRAY /dev/md/pool metadata': '1.2 UUID=567da122:fb8e445e:55b853e0:81bd0a3e name=positron:pool' + }) + mock.assert_called_with('mdadm -Y -E /dev/md0', ignore_retcode=False, + python_shell=False) + + def test_examine_quiet(self): + ''' + Test for mdadm_raid.examine + ''' + mock = MagicMock(return_value='') + with patch.dict(mdadm.__salt__, {'cmd.run_stdout': mock}): + self.assertEqual(mdadm.examine('/dev/md0', quiet=True), {}) + mock.assert_called_with('mdadm -Y -E /dev/md0', ignore_retcode=True, + python_shell=False) diff --git a/tests/unit/modules/test_nacl.py b/tests/unit/modules/test_nacl.py index 20a9b5fc8534..1270a5f7e691 100644 --- a/tests/unit/modules/test_nacl.py +++ b/tests/unit/modules/test_nacl.py @@ -30,7 +30,7 @@ class NaclTest(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): self.unencrypted_data = salt.utils.stringutils.to_bytes('hello') - self.opts = salt.config.DEFAULT_MINION_OPTS + self.opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils(self.opts) funcs = salt.loader.minion_mods(self.opts, utils=utils, whitelist=['nacl']) diff --git a/tests/unit/modules/test_solarisipspkg.py b/tests/unit/modules/test_solarisipspkg.py index c80ca953d951..5742770dcd88 100644 --- a/tests/unit/modules/test_solarisipspkg.py +++ b/tests/unit/modules/test_solarisipspkg.py @@ -27,7 +27,7 @@ class IpsTestCase(TestCase, LoaderModuleMockMixin): Test cases for salt.modules.solarisips ''' def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() utils = salt.loader.utils( opts, whitelist=['pkg', 'path', 'platform']) diff --git a/tests/unit/modules/test_state.py b/tests/unit/modules/test_state.py index 0d15458be0a9..75a3846fef08 100644 --- a/tests/unit/modules/test_state.py +++ b/tests/unit/modules/test_state.py @@ -344,7 +344,7 @@ class StateTestCase(TestCase, LoaderModuleMockMixin): def setup_loader_modules(self): utils = salt.loader.utils( - salt.config.DEFAULT_MINION_OPTS, + salt.config.DEFAULT_MINION_OPTS.copy(), whitelist=['state', 'args', 'systemd', 'path', 'platform'] ) utils.keys() diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py index b6ddd05634c8..19b73979a629 100644 --- a/tests/unit/modules/test_virt.py +++ b/tests/unit/modules/test_virt.py @@ -2663,3 +2663,17 @@ def test_pool_list_volumes(self): self.mock_conn.storagePoolLookupByName.return_value = mock_pool # pylint: enable=no-member self.assertEqual(names, virt.pool_list_volumes('default')) + + @patch('salt.modules.virt._is_kvm_hyper', return_value=True) + @patch('salt.modules.virt._is_xen_hyper', return_value=False) + def test_get_hypervisor(self, isxen_mock, iskvm_mock): + ''' + test the virt.get_hypervisor() function + ''' + self.assertEqual('kvm', virt.get_hypervisor()) + + iskvm_mock.return_value = False + self.assertIsNone(virt.get_hypervisor()) + + isxen_mock.return_value = True + self.assertEqual('xen', virt.get_hypervisor()) diff --git a/tests/unit/modules/test_zfs.py b/tests/unit/modules/test_zfs.py index 9e858e2fcb93..e92cf2701d60 100644 --- a/tests/unit/modules/test_zfs.py +++ b/tests/unit/modules/test_zfs.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -22,9 +23,6 @@ NO_MOCK_REASON, ) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch - # Import Salt Execution module to test import salt.utils.zfs import salt.modules.zfs as zfs @@ -42,7 +40,11 @@ class ZfsTestCase(TestCase, LoaderModuleMockMixin): This class contains a set of functions that test salt.modules.zfs module ''' def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) + utils = salt.loader.utils( opts, whitelist=['zfs', 'args', 'systemd', 'path', 'platform']) @@ -65,7 +67,7 @@ def test_exists_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertTrue(zfs.exists('myzpool/mydataset')) def test_exists_failure_not_exists(self): @@ -78,7 +80,7 @@ def test_exists_failure_not_exists(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertFalse(zfs.exists('myzpool/mydataset')) def test_exists_failure_invalid_name(self): @@ -91,7 +93,7 @@ def test_exists_failure_invalid_name(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertFalse(zfs.exists('myzpool/')) def test_create_success(self): @@ -105,7 +107,7 @@ def test_create_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset')) def test_create_success_with_create_parent(self): @@ -119,7 +121,7 @@ def test_create_success_with_create_parent(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset/mysubdataset', create_parent=True)) def test_create_success_with_properties(self): @@ -133,7 +135,7 @@ def test_create_success_with_properties(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual( res, zfs.create( @@ -159,7 +161,7 @@ def test_create_error_missing_dataset(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool')) def test_create_error_trailing_slash(self): @@ -176,7 +178,7 @@ def test_create_error_trailing_slash(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/')) def test_create_error_no_such_pool(self): @@ -193,7 +195,7 @@ def test_create_error_no_such_pool(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset')) def test_create_error_missing_parent(self): @@ -210,7 +212,7 @@ def test_create_error_missing_parent(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset/mysubdataset')) def test_destroy_success(self): @@ -224,7 +226,7 @@ def test_destroy_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.destroy('myzpool/mydataset')) def test_destroy_error_not_exists(self): @@ -241,7 +243,7 @@ def test_destroy_error_not_exists(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.destroy('myzpool/mydataset')) def test_destroy_error_has_children(self): @@ -266,7 +268,7 @@ def test_destroy_error_has_children(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.destroy('myzpool/mydataset')) def test_rename_success(self): @@ -280,7 +282,7 @@ def test_rename_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rename('myzpool/mydataset', 'myzpool/newdataset')) def test_rename_error_not_exists(self): @@ -297,7 +299,7 @@ def test_rename_error_not_exists(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rename('myzpool/mydataset', 'myzpool/newdataset')) def test_list_success(self): @@ -318,7 +320,7 @@ def test_list_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool')) def test_list_parsable_success(self): @@ -339,7 +341,7 @@ def test_list_parsable_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool', parsable=False)) def test_list_custom_success(self): @@ -360,7 +362,7 @@ def test_list_custom_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool', properties='canmount,used,avail,compression')) def test_list_custom_parsable_success(self): @@ -381,7 +383,7 @@ def test_list_custom_parsable_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool', properties='canmount,used,avail,compression', parsable=False)) def test_list_error_no_dataset(self): @@ -395,7 +397,7 @@ def test_list_error_no_dataset(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool')) def test_list_mount_success(self): @@ -415,7 +417,7 @@ def test_list_mount_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_mount()) def test_mount_success(self): @@ -429,7 +431,7 @@ def test_mount_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.mount('myzpool/mydataset')) def test_mount_failure(self): @@ -443,7 +445,7 @@ def test_mount_failure(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.mount('myzpool/mydataset')) def test_unmount_success(self): @@ -457,7 +459,7 @@ def test_unmount_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.unmount('myzpool/mydataset')) def test_unmount_failure(self): @@ -474,7 +476,7 @@ def test_unmount_failure(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.unmount('myzpool/mydataset')) def test_inherit_success(self): @@ -485,7 +487,7 @@ def test_inherit_success(self): ret = {'pid': 45193, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.inherit('compression', 'myzpool/mydataset')) def test_inherit_failure(self): @@ -499,7 +501,7 @@ def test_inherit_failure(self): ret = {'pid': 43898, 'retcode': 1, 'stderr': "'canmount' property cannot be inherited", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.inherit('canmount', 'myzpool/mydataset')) def test_diff(self): @@ -521,7 +523,7 @@ def test_diff(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.diff('myzpool/mydataset@yesterday', 'myzpool/mydataset')) def test_diff_parsed_time(self): @@ -545,7 +547,7 @@ def test_diff_parsed_time(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.diff('myzpool/data@yesterday', 'myzpool/data', parsable=False)) def test_rollback_success(self): @@ -556,7 +558,7 @@ def test_rollback_success(self): ret = {'pid': 56502, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rollback('myzpool/mydataset@yesterday')) def test_rollback_failure(self): @@ -582,7 +584,7 @@ def test_rollback_failure(self): } mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rollback('myzpool/mydataset@yesterday')) def test_clone_success(self): @@ -593,7 +595,7 @@ def test_clone_success(self): ret = {'pid': 64532, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.clone('myzpool/mydataset@yesterday', 'myzpool/yesterday')) def test_clone_failure(self): @@ -607,7 +609,7 @@ def test_clone_failure(self): ret = {'pid': 64864, 'retcode': 1, 'stderr': "cannot create 'myzpool/archive/yesterday': parent does not exist", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.clone('myzpool/mydataset@yesterday', 'myzpool/archive/yesterday')) def test_promote_success(self): @@ -618,7 +620,7 @@ def test_promote_success(self): ret = {'pid': 69075, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.promote('myzpool/yesterday')) def test_promote_failure(self): @@ -632,7 +634,7 @@ def test_promote_failure(self): ret = {'pid': 69209, 'retcode': 1, 'stderr': "cannot promote 'myzpool/yesterday': not a cloned filesystem", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.promote('myzpool/yesterday')) def test_bookmark_success(self): @@ -644,7 +646,7 @@ def test_bookmark_success(self): ret = {'pid': 20990, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.bookmark('myzpool/mydataset@yesterday', 'myzpool/mydataset#important')) def test_holds_success(self): @@ -658,7 +660,7 @@ def test_holds_success(self): ret = {'pid': 40216, 'retcode': 0, 'stderr': '', 'stdout': 'myzpool/mydataset@baseline\timportant \tWed Dec 23 21:06 2015\nmyzpool/mydataset@baseline\trelease-1.0\tWed Dec 23 21:08 2015'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.holds('myzpool/mydataset@baseline')) def test_holds_failure(self): @@ -671,7 +673,7 @@ def test_holds_failure(self): ret = {'pid': 40993, 'retcode': 1, 'stderr': "cannot open 'myzpool/mydataset@baseline': dataset does not exist", 'stdout': 'no datasets available'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.holds('myzpool/mydataset@baseline')) def test_hold_success(self): @@ -682,7 +684,7 @@ def test_hold_success(self): ret = {'pid': 50876, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.hold('important', 'myzpool/mydataset@baseline', 'myzpool/mydataset@release-1.0')) def test_hold_failure(self): @@ -696,7 +698,7 @@ def test_hold_failure(self): ret = {'pid': 51006, 'retcode': 1, 'stderr': "cannot hold snapshot 'myzpool/mydataset@baseline': tag already exists on this dataset", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.hold('important', 'myzpool/mydataset@baseline')) def test_release_success(self): @@ -707,7 +709,7 @@ def test_release_success(self): ret = {'pid': 50876, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.release('important', 'myzpool/mydataset@baseline', 'myzpool/mydataset@release-1.0')) def test_release_failure(self): @@ -721,7 +723,7 @@ def test_release_failure(self): ret = {'pid': 51006, 'retcode': 1, 'stderr': "cannot release hold from snapshot 'myzpool/mydataset@baseline': no such tag on this dataset", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.release('important', 'myzpool/mydataset@baseline')) def test_snapshot_success(self): @@ -732,7 +734,7 @@ def test_snapshot_success(self): ret = {'pid': 69125, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.snapshot('myzpool/mydataset@baseline')) def test_snapshot_failure(self): @@ -746,7 +748,7 @@ def test_snapshot_failure(self): ret = {'pid': 68526, 'retcode': 1, 'stderr': "cannot create snapshot 'myzpool/mydataset@baseline': dataset already exists", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.snapshot('myzpool/mydataset@baseline')) def test_snapshot_failure2(self): @@ -760,7 +762,7 @@ def test_snapshot_failure2(self): ret = {'pid': 69256, 'retcode': 2, 'stderr': "cannot open 'myzpool/mydataset': dataset does not exist\nusage:\n\tsnapshot [-r] [-o property=value] ... @ ...\n\nFor the property list, run: zfs set|get\n\nFor the delegated permission list, run: zfs allow|unallow", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.snapshot('myzpool/mydataset@baseline')) def test_set_success(self): @@ -771,7 +773,7 @@ def test_set_success(self): ret = {'pid': 79736, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.set('myzpool/mydataset', compression='lz4')) def test_set_failure(self): @@ -785,7 +787,7 @@ def test_set_failure(self): ret = {'pid': 79887, 'retcode': 1, 'stderr': "cannot set property for 'myzpool/mydataset': 'canmount' must be one of 'on | off | noauto'", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.set('myzpool/mydataset', canmount='lz4')) def test_get_success(self): @@ -802,7 +804,7 @@ def test_get_success(self): ret = {'pid': 562, 'retcode': 0, 'stderr': '', 'stdout': 'myzpool\tused\t906238099456'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.get('myzpool', properties='used', fields='value')) def test_get_parsable_success(self): @@ -819,5 +821,5 @@ def test_get_parsable_success(self): ret = {'pid': 562, 'retcode': 0, 'stderr': '', 'stdout': 'myzpool\tused\t906238099456'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.get('myzpool', properties='used', fields='value', parsable=False)) diff --git a/tests/unit/modules/test_zpool.py b/tests/unit/modules/test_zpool.py index 5ac302eb5ac5..d3ad2634b9ac 100644 --- a/tests/unit/modules/test_zpool.py +++ b/tests/unit/modules/test_zpool.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, print_function, unicode_literals # Import Salt Testing libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -22,8 +23,6 @@ NO_MOCK_REASON, ) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch # Import Salt Execution module to test import salt.utils.zfs @@ -43,7 +42,10 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin): This class contains a set of functions that test salt.modules.zpool module ''' def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) utils = salt.loader.utils( opts, whitelist=['zfs', 'args', 'systemd', 'path', 'platform']) @@ -67,7 +69,7 @@ def test_exists_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertTrue(zpool.exists('myzpool')) def test_exists_failure(self): @@ -81,7 +83,7 @@ def test_exists_failure(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertFalse(zpool.exists('myzpool')) def test_healthy(self): @@ -95,7 +97,7 @@ def test_healthy(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertTrue(zpool.healthy()) def test_status(self): @@ -121,7 +123,7 @@ def test_status(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.status() self.assertEqual('ONLINE', ret['mypool']['state']) @@ -144,7 +146,7 @@ def test_iostat(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.iostat('mypool', parsable=False) self.assertEqual('46.7G', ret['mypool']['capacity-alloc']) @@ -172,7 +174,7 @@ def test_iostat_parsable(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.iostat('mypool', parsable=True) self.assertEqual(50143743180, ret['mypool']['capacity-alloc']) @@ -186,7 +188,7 @@ def test_list(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.list_(parsable=False) res = OrderedDict([('mypool', OrderedDict([ ('size', '1.81T'), @@ -208,7 +210,7 @@ def test_list_parsable(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.list_(parsable=True) res = OrderedDict([('mypool', OrderedDict([ ('size', 1990116046274), @@ -230,7 +232,7 @@ def test_get(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.get('mypool', 'size', parsable=False) res = OrderedDict(OrderedDict([('size', '1.81T')])) self.assertEqual(ret, res) @@ -245,7 +247,7 @@ def test_get_parsable(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.get('mypool', 'size', parsable=True) res = OrderedDict(OrderedDict([('size', 1990116046274)])) self.assertEqual(ret, res) @@ -260,7 +262,7 @@ def test_get_whitespace(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.get('mypool', 'comment') res = OrderedDict(OrderedDict([('comment', "my testing pool")])) self.assertEqual(ret, res) @@ -278,7 +280,7 @@ def test_scrub_start(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.scrub('mypool') res = OrderedDict(OrderedDict([('scrubbing', True)])) self.assertEqual(ret, res) @@ -296,7 +298,7 @@ def test_scrub_pause(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.scrub('mypool', pause=True) res = OrderedDict(OrderedDict([('scrubbing', False)])) self.assertEqual(ret, res) @@ -314,7 +316,7 @@ def test_scrub_stop(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.scrub('mypool', stop=True) res = OrderedDict(OrderedDict([('scrubbing', False)])) self.assertEqual(ret, res) @@ -330,7 +332,7 @@ def test_split_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', True)]) self.assertEqual(ret, res) @@ -346,7 +348,7 @@ def test_split_exist_new(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', 'Unable to split datapool: pool already exists')]) self.assertEqual(ret, res) @@ -362,7 +364,7 @@ def test_split_missing_pool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', "cannot open 'datapool': no such pool")]) self.assertEqual(ret, res) @@ -378,7 +380,7 @@ def test_split_not_mirror(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', 'Unable to split datapool: Source pool must be composed only of mirrors')]) self.assertEqual(ret, res) @@ -394,7 +396,7 @@ def test_labelclear_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([('labelcleared', True)]) self.assertEqual(ret, res) @@ -410,7 +412,7 @@ def test_labelclear_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([ ('labelcleared', False), @@ -429,7 +431,7 @@ def test_labelclear_cleared(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([ ('labelcleared', False), @@ -450,7 +452,7 @@ def test_labelclear_exported(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([ ('labelcleared', False), @@ -470,7 +472,7 @@ def test_create_file_vdev_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.create_file_vdev('64M', '/vdisks/disk0') res = OrderedDict([ ('/vdisks/disk0', 'created'), @@ -489,7 +491,7 @@ def test_create_file_vdev_nospace(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.create_file_vdev('64M', '/vdisks/disk0') res = OrderedDict([ ('/vdisks/disk0', 'failed'), @@ -510,7 +512,7 @@ def test_export_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.export('mypool') res = OrderedDict([('exported', True)]) self.assertEqual(ret, res) @@ -526,7 +528,7 @@ def test_export_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.export('mypool') res = OrderedDict([('exported', False), ('error', "cannot open 'mypool': no such pool")]) self.assertEqual(ret, res) @@ -542,7 +544,7 @@ def test_import_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.import_('mypool') res = OrderedDict([('imported', True)]) self.assertEqual(ret, res) @@ -561,7 +563,7 @@ def test_import_duplicate(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.import_('mypool') res = OrderedDict([ ('imported', False), @@ -580,7 +582,7 @@ def test_import_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.import_('mypool') res = OrderedDict([ ('imported', False), @@ -599,7 +601,7 @@ def test_online_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.online('mypool', '/dev/rdsk/c0t0d0') res = OrderedDict([('onlined', True)]) self.assertEqual(ret, res) @@ -615,7 +617,7 @@ def test_online_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.online('mypool', '/dev/rdsk/c0t0d1') res = OrderedDict([ ('onlined', False), @@ -634,7 +636,7 @@ def test_offline_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.offline('mypool', '/dev/rdsk/c0t0d0') res = OrderedDict([('offlined', True)]) self.assertEqual(ret, res) @@ -650,7 +652,7 @@ def test_offline_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.offline('mypool', '/dev/rdsk/c0t0d1') res = OrderedDict([ ('offlined', False), @@ -669,7 +671,7 @@ def test_offline_noreplica(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.offline('mypool', '/dev/rdsk/c0t0d1') res = OrderedDict([ ('offlined', False), @@ -688,7 +690,7 @@ def test_reguid_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reguid('mypool') res = OrderedDict([('reguided', True)]) self.assertEqual(ret, res) @@ -704,7 +706,7 @@ def test_reguid_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reguid('mypool') res = OrderedDict([ ('reguided', False), @@ -723,7 +725,7 @@ def test_reopen_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reopen('mypool') res = OrderedDict([('reopened', True)]) self.assertEqual(ret, res) @@ -739,7 +741,7 @@ def test_reopen_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reopen('mypool') res = OrderedDict([ ('reopened', False), @@ -758,7 +760,7 @@ def test_upgrade_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.upgrade('mypool') res = OrderedDict([('upgraded', True)]) self.assertEqual(ret, res) @@ -774,7 +776,7 @@ def test_upgrade_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.upgrade('mypool') res = OrderedDict([ ('upgraded', False), @@ -797,7 +799,7 @@ def test_history_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.history('mypool') res = OrderedDict([ ('mypool', OrderedDict([ @@ -818,7 +820,7 @@ def test_history_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.history('mypool') res = OrderedDict([ ('error', "cannot open 'mypool': no such pool"), @@ -836,7 +838,7 @@ def test_clear_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.clear('mypool') res = OrderedDict([('cleared', True)]) self.assertEqual(ret, res) @@ -852,7 +854,7 @@ def test_clear_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.clear('mypool') res = OrderedDict([ ('cleared', False), @@ -870,7 +872,7 @@ def test_clear_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.clear('mypool', '/dev/rdsk/c0t0d0') res = OrderedDict([ ('cleared', False), diff --git a/tests/unit/netapi/test_rest_tornado.py b/tests/unit/netapi/test_rest_tornado.py index 96a637b37b82..7ff62b06948e 100644 --- a/tests/unit/netapi/test_rest_tornado.py +++ b/tests/unit/netapi/test_rest_tornado.py @@ -7,7 +7,7 @@ import hashlib # Import Salt Testing Libs -from tests.integration import AdaptedConfigurationTestCaseMixin +from tests.support.mixins import AdaptedConfigurationTestCaseMixin from tests.support.unit import TestCase, skipIf # Import Salt libs diff --git a/tests/unit/pillar/test_hg_pillar.py b/tests/unit/pillar/test_hg_pillar.py index 21e8a9a7e0ef..d79ebb168962 100644 --- a/tests/unit/pillar/test_hg_pillar.py +++ b/tests/unit/pillar/test_hg_pillar.py @@ -10,8 +10,7 @@ import subprocess # Import Salt Testing libs -from tests.integration import AdaptedConfigurationTestCaseMixin -from tests.support.mixins import LoaderModuleMockMixin +from tests.support.mixins import AdaptedConfigurationTestCaseMixin, LoaderModuleMockMixin from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON from tests.support.paths import TMP diff --git a/tests/unit/renderers/test_stateconf.py b/tests/unit/renderers/test_stateconf.py index 38798710d0e0..3acf11e17331 100644 --- a/tests/unit/renderers/test_stateconf.py +++ b/tests/unit/renderers/test_stateconf.py @@ -8,11 +8,11 @@ # Import Salt Testing libs from tests.support.unit import TestCase +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.loader import salt.config -import tests.integration as integration from salt.exceptions import SaltRenderError from salt.ext.six.moves import StringIO @@ -26,7 +26,7 @@ class StateConfigRendererTestCase(TestCase): def setUp(self): - self.root_dir = tempfile.mkdtemp(dir=integration.TMP) + self.root_dir = tempfile.mkdtemp(dir=RUNTIME_VARS.TMP) self.state_tree_dir = os.path.join(self.root_dir, 'state_tree') self.cache_dir = os.path.join(self.root_dir, 'cachedir') if not os.path.isdir(self.root_dir): diff --git a/tests/unit/returners/test_local_cache.py b/tests/unit/returners/test_local_cache.py index 9c987d9b83aa..a04eaee20dc5 100644 --- a/tests/unit/returners/test_local_cache.py +++ b/tests/unit/returners/test_local_cache.py @@ -16,8 +16,7 @@ import time # Import Salt Testing libs -from tests.integration import AdaptedConfigurationTestCaseMixin -from tests.support.mixins import LoaderModuleMockMixin +from tests.support.mixins import AdaptedConfigurationTestCaseMixin, LoaderModuleMockMixin from tests.support.paths import TMP from tests.support.unit import TestCase, skipIf from tests.support.mock import ( diff --git a/tests/unit/returners/test_slack_webhook_return.py b/tests/unit/returners/test_slack_webhook_return.py new file mode 100644 index 000000000000..68c33c58442d --- /dev/null +++ b/tests/unit/returners/test_slack_webhook_return.py @@ -0,0 +1,153 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Carlos D. Álvaro ` + + tests.unit.returners.test_slack_webhook_return + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Unit tests for the Slack Webhook Returner. +''' + +# Import Python libs +from __future__ import absolute_import + +# Import Salt Testing libs +from tests.support.mixins import LoaderModuleMockMixin +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch + +# Import Salt libs +import salt.returners.slack_webhook_return as slack_webhook + + +@skipIf(NO_MOCK, NO_MOCK_REASON) +class SlackWebhookReturnerTestCase(TestCase, LoaderModuleMockMixin): + ''' + Test slack_webhook returner + ''' + _WEBHOOK = 'T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' + _AUTHOR_ICON = 'https://platform.slack-edge.com/img/default_application_icon.png' + _SHOW_TASKS = True + _MINION_NAME = 'MacPro' + + _RET = { + 'fun_args': ['config.vim'], + 'jid': '20181227105933129338', + 'return': + {'file_|-vim files present_|-/Users/cdalvaro/_|-recurse': + {'comment': 'The directory /Users/cdalvaro/ is in the correct state', + 'pchanges': {}, + 'name': '/Users/cdalvaro/', + 'start_time': '10:59:52.252830', + 'result': True, + 'duration': 373.25, + '__run_num__': 3, + '__sls__': 'config.vim', + 'changes': {}, + '__id__': 'vim files present'}, + 'pkg_|-vim present_|-vim_|-installed': + {'comment': 'All specified packages are already installed', + 'name': 'vim', + 'start_time': '10:59:36.830591', + 'result': True, + 'duration': 1280.127, + '__run_num__': 0, + '__sls__': 'config.vim', + 'changes': {}, + '__id__': 'vim present'}, + 'git_|-salt vim plugin updated_|-https://github.com/saltstack/salt-vim.git_|-latest': + {'comment': 'https://github.com/saltstack/salt-vim.git cloned to /Users/cdalvaro/.vim/pack/git-plugins/start/salt', + 'name': 'https://github.com/saltstack/salt-vim.git', + 'start_time': '11:00:01.892757', + 'result': True, + 'duration': 11243.445, + '__run_num__': 6, + '__sls__': 'config.vim', + 'changes': + {'new': 'https://github.com/saltstack/salt-vim.git => /Users/cdalvaro/.vim/pack/git-plugins/start/salt', + 'revision': {'new': '6ca9e3500cc39dd417b411435d58a1b720b331cc', 'old': None}}, + '__id__': 'salt vim plugin updated'}, + 'pkg_|-macvim present_|-caskroom/cask/macvim_|-installed': + {'comment': 'The following packages failed to install/update: caskroom/cask/macvim', + 'name': 'caskroom/cask/macvim', + 'start_time': '10:59:38.111119', + 'result': False, + 'duration': 14135.45, + '__run_num__': 1, + '__sls__': 'config.vim', + 'changes': {}, + '__id__': 'macvim present'}}, + 'retcode': 2, + 'success': True, + 'fun': 'state.apply', + 'id': _MINION_NAME, + 'out': 'highstate' + } + + _EXPECTED_PAYLOAD = { + u'attachments': [ + {u'title': u'Success: False', + u'color': u'#272727', + u'text': u"Function: state.apply\nFunction Args: ['config.vim']\nJID: 20181227105933129338\nTotal: 4\nDuration: 27.03 secs", + u'author_link': u'{}'.format(_MINION_NAME), + u'author_name': u'{}'.format(_MINION_NAME), + u'fallback': u'{} | Failed'.format(_MINION_NAME), + u'author_icon': _AUTHOR_ICON}, + {u'color': u'good', + u'title': u'Unchanged: 2'}, + {u'color': u'warning', + u'fields': [ + {u'short': False, + u'value': u'config.vim.sls | salt vim plugin updated'} + ], + u'title': u'Changed: 1'}, + {u'color': u'danger', + u'fields': [ + {u'short': False, + u'value': u'config.vim.sls | macvim present'} + ], + u'title': u'Failed: 1'} + ] + } + + def setup_loader_modules(self): + return {slack_webhook: {'__opts__': { + 'slack_webhook.webhook': self._WEBHOOK, + 'slack_webhook.author_icon': self._AUTHOR_ICON, + 'slack_webhook.success_title': '{id} | Succeeded', + 'slack_webhook.failure_title': '{id} | Failed', + 'slack_webhook.show_tasks': self._SHOW_TASKS + }}} + + def test_no_webhook(self): + ''' + Test returner stops if no webhook is defined + ''' + with patch.dict(slack_webhook.__opts__, {'slack_webhook.webhook': ''}): + self.assertEqual(slack_webhook.returner(self._RET), None) + + def test_returner(self): + ''' + Test to see if the Slack Webhook returner sends a message + ''' + query_ret = {'body': 'ok', 'status': 200} + with patch('salt.utils.http.query', return_value=query_ret): + self.assertTrue(slack_webhook.returner(self._RET)) + + def test_generate_payload(self): + ''' + Test _generate_payload private method + ''' + test_title = '{} | Failed'.format(self._MINION_NAME) + test_report = slack_webhook._generate_report( + self._RET, self._SHOW_TASKS) + + custom_grains = slack_webhook.__grains__ + custom_grains['id'] = self._MINION_NAME + custom_grains['localhost'] = self._MINION_NAME + + with patch.dict(slack_webhook.__grains__, custom_grains): + test_payload = slack_webhook._generate_payload( + self._AUTHOR_ICON, test_title, test_report) + + self.assertDictEqual(test_payload, self._EXPECTED_PAYLOAD) diff --git a/tests/unit/states/test_boto_apigateway.py b/tests/unit/states/test_boto_apigateway.py index d0fc2f317a20..172921ad3407 100644 --- a/tests/unit/states/test_boto_apigateway.py +++ b/tests/unit/states/test_boto_apigateway.py @@ -397,7 +397,7 @@ class BotoApiGatewayStateTestCaseBase(TestCase, LoaderModuleMockMixin): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_cloudfront.py b/tests/unit/states/test_boto_cloudfront.py index 25f26d561136..a55c0146b046 100644 --- a/tests/unit/states/test_boto_cloudfront.py +++ b/tests/unit/states/test_boto_cloudfront.py @@ -36,7 +36,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.name = 'my_distribution' cls.base_ret = {'name': cls.name, 'changes': {}} diff --git a/tests/unit/states/test_boto_cloudtrail.py b/tests/unit/states/test_boto_cloudtrail.py index 3edd5b259424..d25fd0ab1aa0 100644 --- a/tests/unit/states/test_boto_cloudtrail.py +++ b/tests/unit/states/test_boto_cloudtrail.py @@ -128,7 +128,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_cloudwatch_event.py b/tests/unit/states/test_boto_cloudwatch_event.py index 395a6b30593b..42932373eaa0 100644 --- a/tests/unit/states/test_boto_cloudwatch_event.py +++ b/tests/unit/states/test_boto_cloudwatch_event.py @@ -105,7 +105,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_cognitoidentity.py b/tests/unit/states/test_boto_cognitoidentity.py index f0834a3ce986..6fb21ca1e666 100644 --- a/tests/unit/states/test_boto_cognitoidentity.py +++ b/tests/unit/states/test_boto_cognitoidentity.py @@ -150,7 +150,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_elasticsearch_domain.py b/tests/unit/states/test_boto_elasticsearch_domain.py index e6664ab6674c..ce52a3db3e8b 100644 --- a/tests/unit/states/test_boto_elasticsearch_domain.py +++ b/tests/unit/states/test_boto_elasticsearch_domain.py @@ -108,7 +108,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_iot.py b/tests/unit/states/test_boto_iot.py index 530d88c46440..1ea8ac74d475 100644 --- a/tests/unit/states/test_boto_iot.py +++ b/tests/unit/states/test_boto_iot.py @@ -159,7 +159,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_lambda.py b/tests/unit/states/test_boto_lambda.py index fe92feeeafaa..a8fbb802655d 100644 --- a/tests/unit/states/test_boto_lambda.py +++ b/tests/unit/states/test_boto_lambda.py @@ -127,7 +127,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_s3_bucket.py b/tests/unit/states/test_boto_s3_bucket.py index b3f93c27c5f9..5d166ebf7702 100644 --- a/tests/unit/states/test_boto_s3_bucket.py +++ b/tests/unit/states/test_boto_s3_bucket.py @@ -290,7 +290,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_boto_sqs.py b/tests/unit/states/test_boto_sqs.py index 2b8e46ac88cb..7b4a56214ff1 100644 --- a/tests/unit/states/test_boto_sqs.py +++ b/tests/unit/states/test_boto_sqs.py @@ -35,7 +35,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() @classmethod def tearDownClass(cls): diff --git a/tests/unit/states/test_boto_vpc.py b/tests/unit/states/test_boto_vpc.py index a2a4facb3f65..5db4781fb283 100644 --- a/tests/unit/states/test_boto_vpc.py +++ b/tests/unit/states/test_boto_vpc.py @@ -110,7 +110,7 @@ def setup_loader_modules(self): @classmethod def setUpClass(cls): - cls.opts = salt.config.DEFAULT_MINION_OPTS + cls.opts = salt.config.DEFAULT_MINION_OPTS.copy() cls.opts['grains'] = salt.loader.grains(cls.opts) @classmethod diff --git a/tests/unit/states/test_disk.py b/tests/unit/states/test_disk.py index 8c2e4aa9a619..189fd2b09224 100644 --- a/tests/unit/states/test_disk.py +++ b/tests/unit/states/test_disk.py @@ -13,6 +13,7 @@ NO_MOCK_REASON, MagicMock, patch) +from os import path # Import Salt Libs import salt.states.disk as disk @@ -50,8 +51,12 @@ def setup_loader_modules(self): 'filesystem': 'tmpfs', 'used': '0'} } + + self.mock_data_path = {'/foo': {'available': '42', 'total': '100'}} + self.addCleanup(delattr, self, 'mock_data') - return {disk: {'__salt__': {'disk.usage': MagicMock(return_value=self.mock_data)}}} + self.addCleanup(delattr, self, 'mock_data_path') + return {disk: {'__salt__': {'disk.usage': MagicMock(return_value=self.mock_data), 'status.diskusage': MagicMock(return_value=self.mock_data_path)}}} def test_status_missing(self): ''' @@ -60,7 +65,7 @@ def test_status_missing(self): mock_fs = '/mnt/cheese' mock_ret = {'name': mock_fs, 'result': False, - 'comment': 'Named disk mount not present ', + 'comment': 'Disk mount /mnt/cheese not present. Directory /mnt/cheese does not exist or is not a directory', 'changes': {}, 'data': {}} @@ -203,27 +208,290 @@ def test_status(self): 'changes': {}, 'data': {}} - mock = MagicMock(side_effect=[[], [mock_fs], {mock_fs: {'capacity': '8 %', 'used': '8'}}, - {mock_fs: {'capacity': '22 %', 'used': '22'}}, - {mock_fs: {'capacity': '15 %', 'used': '15'}}]) + data_1 = {'capacity': '8 %', 'used': '8', 'available': '92'} + data_2 = {'capacity': '22 %', 'used': '22', 'available': '78'} + data_3 = {'capacity': '15 %', 'used': '15', 'available': '85'} + mock = MagicMock(side_effect=[[], {mock_fs: data_1}, {mock_fs: data_2}, {mock_fs: data_3}]) with patch.dict(disk.__salt__, {'disk.usage': mock}): - comt = ('Named disk mount not present ') - ret.update({'comment': comt}) - self.assertDictEqual(disk.status(mock_fs), ret) - - comt = ('minimum must be less than maximum ') - ret.update({'comment': comt}) - self.assertDictEqual(disk.status(mock_fs, '10', '20', absolute=True), ret) - - comt = ('Disk used space is below minimum of 10 KB at 8 KB') - ret.update({'comment': comt, 'data': {'capacity': '8 %', 'used': '8'}}) - self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) - - comt = ('Disk used space is above maximum of 20 KB at 22 KB') - ret.update({'comment': comt, 'data': {'capacity': '22 %', 'used': '22'}}) - self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) - - comt = ('Disk used space in acceptable range') - ret.update({'comment': comt, 'result': True, - 'data': {'capacity': '15 %', 'used': '15'}}) - self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) + mock = MagicMock(return_value=False) + with patch.object(path, 'isdir', mock): + comt = 'Disk mount / not present. Directory / does not exist or is not a directory' + ret.update({'comment': comt}) + self.assertDictEqual(disk.status(mock_fs), ret) + + comt = 'minimum must be less than maximum ' + ret.update({'comment': comt}) + self.assertDictEqual(disk.status(mock_fs, '10', '20', absolute=True), ret) + + comt = 'Disk used space is below minimum of 10 KB at 8 KB' + ret.update({'comment': comt, 'data': data_1}) + self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) + + comt = 'Disk used space is above maximum of 20 KB at 22 KB' + ret.update({'comment': comt, 'data': data_2}) + self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) + + comt = 'Disk used space in acceptable range' + ret.update({'comment': comt, 'result': True, 'data': data_3}) + self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) + + def test_path_missing(self): + mock_fs = '/bar' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk mount {0} not present. Directory {0} does not exist or is not a directory'.format( + mock_fs), + 'changes': {}, + 'data': {}} + mock = MagicMock(return_value=False) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '58', '55', absolute=True, free=False), mock_ret) + + # acceptable range + def test_path_used_absolute_acceptable(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '58', '55', absolute=True, free=False), mock_ret) + + def test_path_used_relative_acceptable(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '100%', '57%', absolute=False, free=False), mock_ret) + + def test_path_free_absolute_acceptable(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '100', '42', absolute=True, free=True), mock_ret) + + def test_path_free_relative_acceptable(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '42%', '41%', absolute=False, free=True), mock_ret) + + def test_mount_used_absolute_acceptable(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + self.assertDictEqual(disk.status(mock_fs, '2172881', '2172880', absolute=True, free=False), mock_ret) + + def test_mount_used_relative_acceptable(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + + self.assertDictEqual(disk.status(mock_fs, '7%', '6%', absolute=False, free=False), mock_ret) + + def test_mount_free_absolute_acceptable(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + self.assertDictEqual(disk.status(mock_fs, '37087976', '37087975', absolute=True, free=True), mock_ret) + + def test_mount_free_relative_acceptable(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': True, + 'comment': 'Disk used space in acceptable range', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + + self.assertDictEqual(disk.status(mock_fs, '100%', '94%', absolute=False, free=True), mock_ret) + + # below minimum + def test_path_used_absolute_below(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is below minimum of 59 KB at 58 KB', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '60', '59', absolute=True, free=False), mock_ret) + + def test_path_used_relative_below(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is below minimum of 59 % at 58.0 %', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '60%', '59%', absolute=False, free=False), mock_ret) + + def test_path_free_absolute_below(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is below minimum of 43 KB at 42 KB', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '100', '43', absolute=True, free=True), mock_ret) + + def test_path_free_relative_below(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is below minimum of 43 % at 42.0 %', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '100%', '43%', absolute=False, free=True), mock_ret) + + def test_mount_used_absolute_below(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is below minimum of 2172881 KB at 2172880 KB', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + self.assertDictEqual(disk.status(mock_fs, '2172882', '2172881', absolute=True, free=False), mock_ret) + + def test_mount_used_relative_below(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is below minimum of 7 % at 6 %', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + + self.assertDictEqual(disk.status(mock_fs, '8%', '7%', absolute=False, free=False), mock_ret) + + def test_mount_free_absolute_below(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is below minimum of 37087977 KB at 37087976 KB', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + self.assertDictEqual(disk.status(mock_fs, '37087978', '37087977', absolute=True, free=True), mock_ret) + + def test_mount_free_relative_below(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is below minimum of 95 % at 94 %', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + + self.assertDictEqual(disk.status(mock_fs, '100%', '95%', absolute=False, free=True), mock_ret) + + # above maximum + def test_path_used_absolute_above(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is above maximum of 57 KB at 58 KB', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '57', '56', absolute=True, free=False), mock_ret) + + def test_path_used_relative_above(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is above maximum of 57 % at 58.0 %', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '57%', '56%', absolute=False, free=False), mock_ret) + + def test_path_free_absolute_above(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is above maximum of 41 KB at 42 KB', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '41', '40', absolute=True, free=True), mock_ret) + + def test_path_free_relative_above(self): + mock_fs = '/foo' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is above maximum of 41 % at 42.0 %', + 'changes': {}, + 'data': self.mock_data_path} + mock = MagicMock(return_value=True) + with patch.object(path, 'isdir', mock): + self.assertDictEqual(disk.status(mock_fs, '41%', '40%', absolute=False, free=True), mock_ret) + + def test_mount_used_absolute_above(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is above maximum of 2172879 KB at 2172880 KB', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + self.assertDictEqual(disk.status(mock_fs, '2172879', '2172878', absolute=True, free=False), mock_ret) + + def test_mount_used_relative_above(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk used space is above maximum of 5 % at 6 %', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + + self.assertDictEqual(disk.status(mock_fs, '5%', '4%', absolute=False, free=False), mock_ret) + + def test_mount_free_absolute_above(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is above maximum of 37087975 KB at 37087976 KB', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + self.assertDictEqual(disk.status(mock_fs, '37087975', '37087974', absolute=True, free=True), mock_ret) + + def test_mount_free_relative_above(self): + mock_fs = '/' + mock_ret = {'name': mock_fs, + 'result': False, + 'comment': 'Disk available space is above maximum of 93 % at 94 %', + 'changes': {}, + 'data': self.mock_data[mock_fs]} + + self.assertDictEqual(disk.status(mock_fs, '93%', '92%', absolute=False, free=True), mock_ret) diff --git a/tests/unit/states/test_file.py b/tests/unit/states/test_file.py index 72cc1fe72867..97b948f4469f 100644 --- a/tests/unit/states/test_file.py +++ b/tests/unit/states/test_file.py @@ -1524,7 +1524,7 @@ def test_rename(self): with patch.object(os.path, 'lexists', mock_lex): comt = ('The target file "{0}" exists and will not be ' 'overwritten'.format(name)) - ret.update({'comment': comt, 'result': False}) + ret.update({'comment': comt, 'result': True}) self.assertDictEqual(filestate.rename(name, source), ret) mock_lex = MagicMock(side_effect=[True, True, True]) diff --git a/tests/unit/states/test_hipchat.py b/tests/unit/states/test_hipchat.py deleted file mode 100644 index 722433a4af99..000000000000 --- a/tests/unit/states/test_hipchat.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- -''' - :codeauthor: Jayesh Kariya -''' -# Import Python libs -from __future__ import absolute_import, print_function, unicode_literals - -# Import Salt Testing Libs -from tests.support.mixins import LoaderModuleMockMixin -from tests.support.unit import skipIf, TestCase -from tests.support.mock import ( - NO_MOCK, - NO_MOCK_REASON, - MagicMock, - patch) - -# Import Salt Libs -import salt.states.hipchat as hipchat - - -@skipIf(NO_MOCK, NO_MOCK_REASON) -class HipchatTestCase(TestCase, LoaderModuleMockMixin): - ''' - Test cases for salt.states.hipchat - ''' - def setup_loader_modules(self): - return {hipchat: {}} - - # 'send_message' function tests: 1 - - def test_send_message(self): - ''' - Test to send a message to a Hipchat room. - ''' - name = 'salt' - room_id = '123456' - from_name = 'SuperAdmin' - message = 'This state was executed successfully.' - - ret = {'name': name, - 'result': None, - 'comment': '', - 'changes': {}} - - with patch.dict(hipchat.__opts__, {'test': True}): - comt = ('The following message is to be sent to Hipchat: {0}' - .format(message)) - ret.update({'comment': comt}) - self.assertDictEqual(hipchat.send_message(name, room_id, from_name, - message), ret) - - with patch.dict(hipchat.__opts__, {'test': False}): - comt = ('Hipchat room id is missing: {0}'.format(name)) - ret.update({'comment': comt, 'result': False}) - self.assertDictEqual(hipchat.send_message(name, None, from_name, - message), ret) - - comt = ('Hipchat from name is missing: {0}'.format(name)) - ret.update({'comment': comt}) - self.assertDictEqual(hipchat.send_message(name, room_id, None, - message), ret) - - comt = ('Hipchat message is missing: {0}'.format(name)) - ret.update({'comment': comt}) - self.assertDictEqual(hipchat.send_message(name, room_id, from_name, - None), ret) - - mock = MagicMock(return_value=True) - with patch.dict(hipchat.__salt__, {'hipchat.send_message': mock}): - comt = ('Sent message: {0}'.format(name)) - ret.update({'comment': comt, 'result': True}) - self.assertDictEqual(hipchat.send_message(name, room_id, - from_name, message), - ret) diff --git a/tests/unit/states/test_saltmod.py b/tests/unit/states/test_saltmod.py index 2408ead9e136..a2e8c7054894 100644 --- a/tests/unit/states/test_saltmod.py +++ b/tests/unit/states/test_saltmod.py @@ -34,7 +34,7 @@ class SaltmodTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): utils = salt.loader.utils( - salt.config.DEFAULT_MINION_OPTS, + salt.config.DEFAULT_MINION_OPTS.copy(), whitelist=['state'] ) return { diff --git a/tests/unit/states/test_zfs.py b/tests/unit/states/test_zfs.py index 421db9225e5d..0d673958c8b7 100644 --- a/tests/unit/states/test_zfs.py +++ b/tests/unit/states/test_zfs.py @@ -12,6 +12,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing Libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -20,9 +21,6 @@ MagicMock, patch) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch - # Import Salt Execution module to test import salt.utils.zfs import salt.states.zfs as zfs @@ -38,7 +36,10 @@ class ZfsTestCase(TestCase, LoaderModuleMockMixin): Test cases for salt.states.zfs ''' def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) utils = salt.loader.utils(opts, whitelist=['zfs']) zfs_obj = { zfs: { @@ -61,7 +62,7 @@ def test_filesystem_absent_nofs(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_absent('myzpool/filesystem')) def test_filesystem_absent_removed(self): @@ -77,7 +78,7 @@ def test_filesystem_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_absent('myzpool/filesystem')) def test_filesystem_absent_fail(self): @@ -104,7 +105,7 @@ def test_filesystem_absent_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_absent('myzpool/filesystem')) def test_volume_absent_novol(self): @@ -118,7 +119,7 @@ def test_volume_absent_novol(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_absent('myzpool/volume')) def test_volume_absent_removed(self): @@ -134,7 +135,7 @@ def test_volume_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_absent('myzpool/volume')) def test_volume_absent_fail(self): @@ -161,7 +162,7 @@ def test_volume_absent_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_absent('myzpool/volume')) def test_snapshot_absent_nosnap(self): @@ -175,7 +176,7 @@ def test_snapshot_absent_nosnap(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_absent('myzpool/filesystem@snap')) def test_snapshot_absent_removed(self): @@ -191,7 +192,7 @@ def test_snapshot_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_absent('myzpool/filesystem@snap')) def test_snapshot_absent_fail(self): @@ -210,7 +211,7 @@ def test_snapshot_absent_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_absent('myzpool/filesystem@snap')) def test_bookmark_absent_nobook(self): @@ -224,7 +225,7 @@ def test_bookmark_absent_nobook(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_absent('myzpool/filesystem#book')) def test_bookmark_absent_removed(self): @@ -240,7 +241,7 @@ def test_bookmark_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_absent('myzpool/filesystem#book')) def test_hold_absent_nohold(self): @@ -254,7 +255,7 @@ def test_hold_absent_nohold(self): mock_holds = MagicMock(return_value=OrderedDict([])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_absent('myhold', 'myzpool/filesystem@snap')) def test_hold_absent_removed(self): @@ -274,7 +275,7 @@ def test_hold_absent_removed(self): mock_release = MagicMock(return_value=OrderedDict([('released', True)])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ patch.dict(zfs.__salt__, {'zfs.release': mock_release}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_absent('myhold', 'myzpool/filesystem@snap')) def test_hold_absent_fail(self): @@ -290,7 +291,7 @@ def test_hold_absent_fail(self): ('error', "cannot open 'myzpool/filesystem@snap': dataset does not exist"), ])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_absent('myhold', 'myzpool/filesystem@snap')) def test_hold_present(self): @@ -304,7 +305,7 @@ def test_hold_present(self): mock_holds = MagicMock(return_value=OrderedDict([('myhold', 'Thu Feb 15 16:24 2018')])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_present('myhold', 'myzpool/filesystem@snap')) def test_hold_present_new(self): @@ -320,7 +321,7 @@ def test_hold_present_new(self): mock_hold = MagicMock(return_value=OrderedDict([('held', True)])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ patch.dict(zfs.__salt__, {'zfs.hold': mock_hold}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_present('myhold', 'myzpool/filesystem@snap')) def test_hold_present_fail(self): @@ -339,7 +340,7 @@ def test_hold_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ patch.dict(zfs.__salt__, {'zfs.hold': mock_hold}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_present('myhold', 'myzpool/filesystem@snap')) def test_filesystem_present(self): @@ -364,7 +365,7 @@ def test_filesystem_present(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present('myzpool/filesystem')) def test_filesystem_present_new(self): @@ -380,7 +381,7 @@ def test_filesystem_present_new(self): mock_create = MagicMock(return_value=OrderedDict([('created', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present('myzpool/filesystem')) def test_filesystem_present_update(self): @@ -407,7 +408,7 @@ def test_filesystem_present_update(self): with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ patch.dict(zfs.__salt__, {'zfs.set': mock_set}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present( name='myzpool/filesystem', properties={'compression': 'lz4'}, @@ -429,7 +430,7 @@ def test_filesystem_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present('myzpool/filesystem')) def test_volume_present(self): @@ -454,7 +455,7 @@ def test_volume_present(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present('myzpool/volume', volume_size='1G')) def test_volume_present_new(self): @@ -470,7 +471,7 @@ def test_volume_present_new(self): mock_create = MagicMock(return_value=OrderedDict([('created', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present('myzpool/volume', volume_size='1G')) def test_volume_present_update(self): @@ -497,7 +498,7 @@ def test_volume_present_update(self): with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ patch.dict(zfs.__salt__, {'zfs.set': mock_set}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present( name='myzpool/volume', volume_size='1G', @@ -520,7 +521,7 @@ def test_volume_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present('myzpool/volume', volume_size='1G')) def test_bookmark_present(self): @@ -534,7 +535,7 @@ def test_bookmark_present(self): mock_exists = MagicMock(return_value=True) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_present('mybookmark', 'myzpool/filesystem@snap')) def test_bookmark_present_new(self): @@ -550,7 +551,7 @@ def test_bookmark_present_new(self): mock_bookmark = MagicMock(return_value=OrderedDict([('bookmarked', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.bookmark': mock_bookmark}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_present('mybookmark', 'myzpool/filesystem@snap')) def test_bookmark_present_fail(self): @@ -569,7 +570,7 @@ def test_bookmark_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.bookmark': mock_bookmark}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_present('mybookmark', 'myzpool/filesystem@snap')) def test_snapshot_present(self): @@ -583,7 +584,7 @@ def test_snapshot_present(self): mock_exists = MagicMock(return_value=True) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_present('myzpool/filesystem@snap')) def test_snapshot_present_new(self): @@ -599,7 +600,7 @@ def test_snapshot_present_new(self): mock_snapshot = MagicMock(return_value=OrderedDict([('snapshotted', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.snapshot': mock_snapshot}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_present('myzpool/filesystem@snap')) def test_snapshot_present_fail(self): @@ -618,7 +619,7 @@ def test_snapshot_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.snapshot': mock_snapshot}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_present('myzpool/filesystem@snap')) def test_propmoted(self): @@ -640,7 +641,7 @@ def test_propmoted(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.promoted('myzpool/filesystem')) def test_propmoted_clone(self): @@ -664,7 +665,7 @@ def test_propmoted_clone(self): with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ patch.dict(zfs.__salt__, {'zfs.promote': mock_promote}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.promoted('myzpool/filesystem')) def test_propmoted_fail(self): @@ -678,7 +679,7 @@ def test_propmoted_fail(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.promoted('myzpool/filesystem')) def test_scheduled_snapshot_fail(self): @@ -692,5 +693,5 @@ def test_scheduled_snapshot_fail(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.scheduled_snapshot('myzpool/filesystem', 'shadow', schedule={'hour': 6})) diff --git a/tests/unit/states/test_zpool.py b/tests/unit/states/test_zpool.py index 79621149d577..d41ced75010a 100644 --- a/tests/unit/states/test_zpool.py +++ b/tests/unit/states/test_zpool.py @@ -12,6 +12,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing Libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -20,9 +21,6 @@ MagicMock, patch) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch - # Import Salt Execution module to test import salt.utils.zfs import salt.states.zpool as zpool @@ -38,7 +36,10 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin): Test cases for salt.states.zpool ''' def setup_loader_modules(self): - self.opts = opts = salt.config.DEFAULT_MINION_OPTS + self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) utils = salt.loader.utils(opts, whitelist=['zfs']) zpool_obj = { zpool: { @@ -61,7 +62,7 @@ def test_absent_without_pool(self): mock_exists = MagicMock(return_value=False) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool'), ret) def test_absent_destroy_pool(self): @@ -81,7 +82,7 @@ def test_absent_destroy_pool(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.destroy': mock_destroy}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool'), ret) def test_absent_exporty_pool(self): @@ -101,7 +102,7 @@ def test_absent_exporty_pool(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.export': mock_destroy}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool', export=True), ret) def test_absent_busy(self): @@ -128,7 +129,7 @@ def test_absent_busy(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.export': mock_destroy}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool', export=True), ret) def test_present_import_success(self): @@ -150,7 +151,7 @@ def test_present_import_success(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.import': mock_import}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.present('myzpool', config=config), ret) def test_present_import_fail(self): @@ -172,7 +173,7 @@ def test_present_import_fail(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.import': mock_import}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.present('myzpool', config=config), ret) def test_present_create_success(self): @@ -208,7 +209,7 @@ def test_present_create_success(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.create': mock_create}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', @@ -235,7 +236,7 @@ def test_present_create_fail(self): mock_exists = MagicMock(return_value=False) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.present('myzpool', config=config), ret) def test_present_create_passthrough_fail(self): @@ -279,7 +280,7 @@ def test_present_create_passthrough_fail(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.create': mock_create}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', @@ -361,7 +362,7 @@ def test_present_update_success(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.get': mock_get}), \ patch.dict(zpool.__salt__, {'zpool.set': mock_set}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', @@ -438,7 +439,7 @@ def test_present_update_nochange_success(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.get': mock_get}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 08f27f5bd5bf..620aeeb50b82 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -7,9 +7,9 @@ from __future__ import absolute_import, print_function, unicode_literals # Import Salt Testing libs -import tests.integration as integration -from tests.support.unit import TestCase, skipIf +from tests.support.mixins import SaltClientTestCaseMixin from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf # Import Salt libs from salt import client @@ -21,7 +21,7 @@ @skipIf(NO_MOCK, NO_MOCK_REASON) class LocalClientTestCase(TestCase, - integration.SaltClientTestCaseMixin): + SaltClientTestCaseMixin): def test_create_local_client(self): local_client = client.LocalClient(mopts=self.get_temp_config('master')) diff --git a/tests/unit/test_fileclient.py b/tests/unit/test_fileclient.py index bb3945ce5039..030c9fa953c1 100644 --- a/tests/unit/test_fileclient.py +++ b/tests/unit/test_fileclient.py @@ -11,8 +11,7 @@ import shutil # Import Salt Testing libs -from tests.integration import AdaptedConfigurationTestCaseMixin -from tests.support.mixins import LoaderModuleMockMixin +from tests.support.mixins import AdaptedConfigurationTestCaseMixin, LoaderModuleMockMixin from tests.support.mock import patch, Mock, MagicMock, NO_MOCK, NO_MOCK_REASON from tests.support.paths import TMP from tests.support.unit import TestCase, skipIf diff --git a/tests/unit/test_minion.py b/tests/unit/test_minion.py index 5cba6f7c9524..632b90739293 100644 --- a/tests/unit/test_minion.py +++ b/tests/unit/test_minion.py @@ -116,7 +116,7 @@ def test_handle_decoded_payload_jid_match_in_jid_queue(self): return None BEFORE any of the processes are spun up because we should be avoiding firing duplicate jobs. ''' - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() mock_data = {'fun': 'foo.bar', 'jid': 123} mock_jid_queue = [123] @@ -137,7 +137,7 @@ def test_handle_decoded_payload_jid_queue_addition(self): patch('salt.utils.process.SignalHandlingProcess.start', MagicMock(return_value=True)), \ patch('salt.utils.process.SignalHandlingProcess.join', MagicMock(return_value=True)): mock_jid = 11111 - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() mock_data = {'fun': 'foo.bar', 'jid': mock_jid} mock_jid_queue = [123, 456] @@ -165,7 +165,7 @@ def test_handle_decoded_payload_jid_queue_reduced_minion_jid_queue_hwm(self): with patch('salt.minion.Minion.ctx', MagicMock(return_value={})), \ patch('salt.utils.process.SignalHandlingProcess.start', MagicMock(return_value=True)), \ patch('salt.utils.process.SignalHandlingProcess.join', MagicMock(return_value=True)): - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() mock_opts['minion_jid_queue_hwm'] = 2 mock_data = {'fun': 'foo.bar', 'jid': 789} @@ -196,7 +196,8 @@ def test_process_count_max(self): patch('salt.utils.minion.running', MagicMock(return_value=[])), \ patch('tornado.gen.sleep', MagicMock(return_value=tornado.concurrent.Future())): process_count_max = 10 - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() + mock_opts['__role'] = 'minion' mock_opts['minion_jid_queue_hwm'] = 100 mock_opts["process_count_max"] = process_count_max diff --git a/tests/unit/test_module_names.py b/tests/unit/test_module_names.py index 0e3863eda18a..594aa0437688 100644 --- a/tests/unit/test_module_names.py +++ b/tests/unit/test_module_names.py @@ -15,7 +15,7 @@ # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.paths import CODE_DIR, test_mods +from tests.support.paths import CODE_DIR, list_test_mods EXCLUDED_DIRS = [ os.path.join('tests', 'pkg'), @@ -72,7 +72,7 @@ def test_module_name(self): excluded_dirs, included_dirs = tuple(EXCLUDED_DIRS), tuple(INCLUDED_DIRS) tests_dir = os.path.join(CODE_DIR, 'tests') bad_names = [] - for root, dirs, files in salt.utils.path.os_walk(tests_dir): + for root, _, files in salt.utils.path.os_walk(tests_dir): reldir = os.path.relpath(root, CODE_DIR) if (reldir.startswith(excluded_dirs) and not self._match_dirs(reldir, included_dirs)) \ or reldir.endswith('__pycache__'): @@ -89,7 +89,7 @@ def test_module_name(self): error_msg = '\n\nPlease rename the following files:\n' for path in bad_names: directory, filename = path.rsplit(os.sep, 1) - filename, ext = os.path.splitext(filename) + filename, _ = os.path.splitext(filename) error_msg += ' {} -> {}/test_{}.py\n'.format(path, directory, filename.split('_test')[0]) error_msg += '\nIf you believe one of the entries above should be ignored, please add it to either\n' @@ -135,6 +135,7 @@ def test_module_name_source_match(self): 'integration.master.test_event_return', 'integration.minion.test_blackout', 'integration.minion.test_pillar', + 'integration.minion.test_executor', 'integration.minion.test_timeout', 'integration.modules.test_decorators', 'integration.modules.test_pkg', @@ -205,7 +206,7 @@ def _format_errors(errors): msg += ''.join(errors) return msg - for mod_name in test_mods(): + for mod_name in list_test_mods(): if mod_name in ignore: # Test module is being ignored, skip it continue diff --git a/tests/unit/test_proxy_minion.py b/tests/unit/test_proxy_minion.py index d79bbcb790e6..67e00091e7cd 100644 --- a/tests/unit/test_proxy_minion.py +++ b/tests/unit/test_proxy_minion.py @@ -31,7 +31,7 @@ def test_post_master_init_metaproxy_called(self): ''' Tests that when the _post_master_ini function is called, _metaproxy_call is also called. ''' - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() mock_jid_queue = [123] proxy_minion = salt.minion.ProxyMinion(mock_opts, jid_queue=copy.copy(mock_jid_queue), io_loop=tornado.ioloop.IOLoop()) try: @@ -44,7 +44,7 @@ def test_handle_decoded_payload_metaproxy_called(self): ''' Tests that when the _handle_decoded_payload function is called, _metaproxy_call is also called. ''' - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() mock_data = {'fun': 'foo.bar', 'jid': 123} mock_jid_queue = [123] @@ -61,7 +61,7 @@ def test_handle_payload_metaproxy_called(self): ''' Tests that when the _handle_payload function is called, _metaproxy_call is also called. ''' - mock_opts = salt.config.DEFAULT_MINION_OPTS + mock_opts = salt.config.DEFAULT_MINION_OPTS.copy() mock_data = {'fun': 'foo.bar', 'jid': 123} mock_jid_queue = [123] diff --git a/tests/unit/test_state.py b/tests/unit/test_state.py index 462539b68a66..8722655eabbc 100644 --- a/tests/unit/test_state.py +++ b/tests/unit/test_state.py @@ -10,7 +10,6 @@ import tempfile # Import Salt Testing libs -import tests.integration as integration from tests.support.unit import TestCase, skipIf from tests.support.mock import ( NO_MOCK, @@ -19,6 +18,7 @@ patch) from tests.support.mixins import AdaptedConfigurationTestCaseMixin from tests.support.paths import BASE_FILES +from tests.support.runtests import RUNTIME_VARS # Import Salt libs import salt.exceptions @@ -76,7 +76,7 @@ def test_render_error_on_invalid_requisite(self): class HighStateTestCase(TestCase, AdaptedConfigurationTestCaseMixin): def setUp(self): - root_dir = tempfile.mkdtemp(dir=integration.TMP) + root_dir = tempfile.mkdtemp(dir=RUNTIME_VARS.TMP) self.state_tree_dir = os.path.join(root_dir, 'state_tree') cache_dir = os.path.join(root_dir, 'cachedir') for dpath in (root_dir, self.state_tree_dir, cache_dir): diff --git a/tests/unit/utils/test_cache.py b/tests/unit/utils/test_cache.py index 65e83408dbae..26636d2607f0 100644 --- a/tests/unit/utils/test_cache.py +++ b/tests/unit/utils/test_cache.py @@ -68,7 +68,7 @@ def test_smoke_context(self): if os.path.exists(os.path.join(tempfile.gettempdir(), 'context')): self.skipTest('Context dir already exists') else: - opts = salt.config.DEFAULT_MINION_OPTS + opts = salt.config.DEFAULT_MINION_OPTS.copy() opts['cachedir'] = tempfile.gettempdir() context_cache = cache.ContextCache(opts, 'cache_test') @@ -84,7 +84,7 @@ def test_context_wrapper(self): with a context cache can store and retrieve its contextual data ''' - opts = salt.config.DEFAULT_MINION_OPTS + opts = salt.config.DEFAULT_MINION_OPTS.copy() opts['cachedir'] = tempfile.gettempdir() ll_ = salt.loader.LazyLoader( diff --git a/tests/unit/utils/test_event.py b/tests/unit/utils/test_event.py index a06982212b54..d54a556fa7cb 100644 --- a/tests/unit/utils/test_event.py +++ b/tests/unit/utils/test_event.py @@ -24,19 +24,19 @@ # Import Salt Testing libs from tests.support.unit import expectedFailure, skipIf, TestCase +from tests.support.runtests import RUNTIME_VARS # Import salt libs import salt.config import salt.utils.event import salt.utils.stringutils -import tests.integration as integration from salt.utils.process import clean_proc # Import 3rd-+arty libs from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin from tests.support.processes import terminate_process -SOCK_DIR = os.path.join(integration.TMP, 'test-socks') +SOCK_DIR = os.path.join(RUNTIME_VARS.TMP, 'test-socks') NO_LONG_IPC = False if getattr(zmq, 'IPC_PATH_MAX_LEN', 103) <= 103: diff --git a/tests/unit/utils/test_extend.py b/tests/unit/utils/test_extend.py index 9cbb767ca503..fd09071de93f 100644 --- a/tests/unit/utils/test_extend.py +++ b/tests/unit/utils/test_extend.py @@ -16,9 +16,9 @@ # Import Salt Testing libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, patch +from tests.support.paths import CODE_DIR # Import salt libs -import tests.integration as integration import salt.utils.extend import salt.utils.files @@ -26,7 +26,7 @@ class ExtendTestCase(TestCase): def setUp(self): self.starting_dir = os.getcwd() - os.chdir(integration.CODE_DIR) + os.chdir(CODE_DIR) self.out = None def tearDown(self): @@ -35,11 +35,11 @@ def tearDown(self): shutil.rmtree(self.out, True) os.chdir(self.starting_dir) - @skipIf(not os.path.exists(os.path.join(integration.CODE_DIR, 'templates')), + @skipIf(not os.path.exists(os.path.join(CODE_DIR, 'templates')), "Test template directory 'templates/' missing.") def test_run(self): with patch('sys.exit', MagicMock): - out = salt.utils.extend.run('test', 'test', 'this description', integration.CODE_DIR, False) + out = salt.utils.extend.run('test', 'test', 'this description', CODE_DIR, False) self.out = out year = date.today().strftime('%Y') self.assertTrue(os.path.exists(out)) diff --git a/tests/unit/utils/test_parsers.py b/tests/unit/utils/test_parsers.py index 176e8eb7b250..45c34a0937fd 100644 --- a/tests/unit/utils/test_parsers.py +++ b/tests/unit/utils/test_parsers.py @@ -569,7 +569,7 @@ def setUp(self): Setting up ''' # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -600,7 +600,7 @@ def setUp(self): Setting up ''' # Set defaults - self.default_config = salt.config.DEFAULT_MINION_OPTS + self.default_config = salt.config.DEFAULT_MINION_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -665,7 +665,7 @@ def setUp(self): self.logfile_config_setting_name = 'syndic_log_file' # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -701,7 +701,7 @@ def setUp(self): self.args = ['foo', 'bar.baz'] # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -734,7 +734,7 @@ def setUp(self): self.args = ['foo', 'bar', 'baz'] # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -769,7 +769,7 @@ def setUp(self): self.logfile_config_setting_name = 'key_logfile' # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -890,7 +890,7 @@ def setUp(self): self.args = ['foo.bar'] # Set defaults - self.default_config = salt.config.DEFAULT_MINION_OPTS + self.default_config = salt.config.DEFAULT_MINION_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -923,7 +923,7 @@ def setUp(self): self.args = ['foo.bar'] # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file @@ -959,7 +959,7 @@ def setUp(self): self.logfile_config_setting_name = 'ssh_log_file' # Set defaults - self.default_config = salt.config.DEFAULT_MASTER_OPTS + self.default_config = salt.config.DEFAULT_MASTER_OPTS.copy() self.addCleanup(delattr, self, 'default_config') # Log file diff --git a/tests/unit/utils/test_pyobjects.py b/tests/unit/utils/test_pyobjects.py index 8908d63f061d..70daf6e7f51e 100644 --- a/tests/unit/utils/test_pyobjects.py +++ b/tests/unit/utils/test_pyobjects.py @@ -12,9 +12,9 @@ # Import Salt Testing libs from tests.support.unit import TestCase +from tests.support.runtests import RUNTIME_VARS # Import Salt libs -import tests.integration as integration import salt.config import salt.state import salt.utils.files @@ -270,7 +270,7 @@ class so that our setUp & tearDown get invoked first, and super can def setUp(self, *args, **kwargs): super(RendererMixin, self).setUp(*args, **kwargs) - self.root_dir = tempfile.mkdtemp('pyobjects_test_root', dir=integration.TMP) + self.root_dir = tempfile.mkdtemp('pyobjects_test_root', dir=RUNTIME_VARS.TMP) self.state_tree_dir = os.path.join(self.root_dir, 'state_tree') self.cache_dir = os.path.join(self.root_dir, 'cachedir') if not os.path.isdir(self.root_dir): diff --git a/tests/unit/utils/test_schedule.py b/tests/unit/utils/test_schedule.py index 8e91de417907..904b46bbb1d2 100644 --- a/tests/unit/utils/test_schedule.py +++ b/tests/unit/utils/test_schedule.py @@ -13,7 +13,7 @@ # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -import tests.integration as integration +from tests.support.runtests import RUNTIME_VARS # Import Salt Libs import salt.config @@ -38,7 +38,7 @@ class ScheduleTestCase(TestCase): @classmethod def setUpClass(cls): - root_dir = os.path.join(integration.TMP, 'schedule-unit-tests') + root_dir = os.path.join(RUNTIME_VARS.TMP, 'schedule-unit-tests') default_config = salt.config.minion_config(None) default_config['conf_dir'] = default_config['root_dir'] = root_dir default_config['sock_dir'] = os.path.join(root_dir, 'test-socks') diff --git a/tests/unit/utils/test_versions.py b/tests/unit/utils/test_versions.py index fb9a9cd673d2..a25feb2a942d 100644 --- a/tests/unit/utils/test_versions.py +++ b/tests/unit/utils/test_versions.py @@ -16,9 +16,9 @@ import warnings # Import Salt Testing libs -import tests.integration as integration from tests.support.unit import TestCase, skipIf from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.paths import CODE_DIR # Import Salt libs import salt.modules.cmdmod @@ -106,12 +106,10 @@ def test_spelling_version_name(self): check the spelling of the version name for the release names in the salt.utils.versions.warn_until call ''' - salt_dir = integration.CODE_DIR query = 'salt.utils.versions.warn_until(' names = salt.version.SaltStackVersion.NAMES - salt_dir += '/salt/' - cmd = 'grep -lr {0} -A 1 '.format(query) + salt_dir + cmd = 'grep -lr {} -A 1 {}'.format(query, os.path.join(CODE_DIR, 'salt')) grep_call = salt.modules.cmdmod.run_stdout(cmd=cmd).split(os.linesep) diff --git a/tests/unit/utils/test_zfs.py b/tests/unit/utils/test_zfs.py index 29b3fe893f49..37ad70df0870 100644 --- a/tests/unit/utils/test_zfs.py +++ b/tests/unit/utils/test_zfs.py @@ -14,6 +14,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing libs +from tests.support.zfs import ZFSMockData from tests.support.unit import skipIf, TestCase from tests.support.mock import ( MagicMock, @@ -26,863 +27,8 @@ import salt.utils.zfs as zfs # Import Salt Utils -import salt.loader from salt.utils.odict import OrderedDict -# property_map mocks -pmap_exec_zpool = { - 'retcode': 2, - 'stdout': '', - 'stderr': "\n".join([ - 'missing property argument', - 'usage:', - ' get [-Hp] [-o "all" | field[,...]] <"all" | property[,...]> ...', - '', - 'the following properties are supported:', - '', - ' PROPERTY EDIT VALUES', - '', - ' allocated NO ', - ' capacity NO ', - ' dedupratio NO <1.00x or higher if deduped>', - ' expandsize NO ', - ' fragmentation NO ', - ' free NO ', - ' freeing NO ', - ' guid NO ', - ' health NO ', - ' leaked NO ', - ' size NO ', - ' altroot YES ', - ' autoexpand YES on | off', - ' autoreplace YES on | off', - ' bootfs YES ', - ' bootsize YES ', - ' cachefile YES | none', - ' comment YES ', - ' dedupditto YES ', - ' delegation YES on | off', - ' failmode YES wait | continue | panic', - ' listsnapshots YES on | off', - ' readonly YES on | off', - ' version YES ', - ' feature@... YES disabled | enabled | active', - '', - 'The feature@ properties must be appended with a feature name.', - 'See zpool-features(5). ', - ]), -} -pmap_zpool = { - 'comment': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'freeing': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'listsnapshots': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'leaked': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'version': { - 'edit': True, - 'type': 'numeric', - 'values': '' - }, - 'write': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'replace': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'delegation': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'dedupditto': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'autoexpand': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'alloc': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'allocated': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'guid': { - 'edit': False, - 'type': 'numeric', - 'values': '' - }, - 'size': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'cap': { - 'edit': False, - 'type': 'numeric', - 'values': '' - }, - 'capacity': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - "capacity-alloc": { - "edit": False, - "type": "size", - "values": "" - }, - "capacity-free": { - "edit": False, - "type": "size", - "values": "" - }, - 'cachefile': { - 'edit': True, - 'type': 'str', - 'values': ' | none' - }, - "cksum": { - "edit": False, - "type": "numeric", - "values": "" - }, - 'bootfs': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'autoreplace': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - "bandwith-read": { - "edit": False, - "type": "size", - "values": "" - }, - "bandwith-write": { - "edit": False, - "type": "size", - "values": "" - }, - "operations-read": { - "edit": False, - "type": "size", - "values": "" - }, - "operations-write": { - "edit": False, - "type": "size", - "values": "" - }, - "read": { - "edit": False, - "type": "size", - "values": "" - }, - 'readonly': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'dedupratio': { - 'edit': False, - 'type': 'str', - 'values': '<1.00x or higher if deduped>' - }, - 'health': { - 'edit': False, - 'type': 'str', - 'values': '' - }, - 'feature@': { - 'edit': True, - 'type': 'str', - 'values': 'disabled | enabled | active' - }, - 'expandsize': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'listsnaps': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'bootsize': { - 'edit': True, - 'type': 'size', - 'values': '' - }, - 'free': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'failmode': { - 'edit': True, - 'type': 'str', - 'values': 'wait | continue | panic' - }, - 'altroot': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'expand': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'frag': { - 'edit': False, - 'type': 'str', - 'values': '' - }, - 'fragmentation': { - 'edit': False, - 'type': 'str', - 'values': '' - } -} -pmap_exec_zfs = { - 'retcode': 2, - 'stdout': '', - 'stderr': "\n".join([ - 'missing property argument', - 'usage:', - ' get [-crHp] [-d max] [-o "all" | field[,...]]', - ' [-t type[,...]] [-s source[,...]]', - ' <"all" | property[,...]> [filesystem|volume|snapshot|bookmark] ...', - '', - 'The following properties are supported:', - '', - ' PROPERTY EDIT INHERIT VALUES', - '', - ' available NO NO ', - ' clones NO NO [,...]', - ' compressratio NO NO <1.00x or higher if compressed>', - ' creation NO NO ', - ' defer_destroy NO NO yes | no', - ' filesystem_count NO NO ', - ' logicalreferenced NO NO ', - ' logicalused NO NO ', - ' mounted NO NO yes | no', - ' origin NO NO ', - ' receive_resume_token NO NO ', - ' refcompressratio NO NO <1.00x or higher if compressed>', - ' referenced NO NO ', - ' snapshot_count NO NO ', - ' type NO NO filesystem | volume | snapshot | bookmark', - ' used NO NO ', - ' usedbychildren NO NO ', - ' usedbydataset NO NO ', - ' usedbyrefreservation NO NO ', - ' usedbysnapshots NO NO ', - ' userrefs NO NO ', - ' written NO NO ', - ' aclinherit YES YES discard | noallow | restricted | passthrough | passthrough-x', - ' aclmode YES YES discard | groupmask | passthrough | restricted', - ' atime YES YES on | off', - ' canmount YES NO on | off | noauto', - ' casesensitivity NO YES sensitive | insensitive | mixed', - ' checksum YES YES on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr', - ' compression YES YES on | off | lzjb | gzip | gzip-[1-9] | zle | lz4', - ' copies YES YES 1 | 2 | 3', - ' dedup YES YES on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify', - ' devices YES YES on | off', - ' exec YES YES on | off', - ' filesystem_limit YES NO | none', - ' logbias YES YES latency | throughput', - ' mlslabel YES YES ', - ' mountpoint YES YES | legacy | none', - ' nbmand YES YES on | off', - ' normalization NO YES none | formC | formD | formKC | formKD', - ' primarycache YES YES all | none | metadata', - ' quota YES NO | none', - ' readonly YES YES on | off', - ' recordsize YES YES 512 to 1M, power of 2', - ' redundant_metadata YES YES all | most', - ' refquota YES NO | none', - ' refreservation YES NO | none', - ' reservation YES NO | none', - ' secondarycache YES YES all | none | metadata', - ' setuid YES YES on | off', - ' sharenfs YES YES on | off | share(1M) options', - ' sharesmb YES YES on | off | sharemgr(1M) options', - ' snapdir YES YES hidden | visible', - ' snapshot_limit YES NO | none', - ' sync YES YES standard | always | disabled', - ' utf8only NO YES on | off', - ' version YES NO 1 | 2 | 3 | 4 | 5 | current', - ' volblocksize NO YES 512 to 128k, power of 2', - ' volsize YES NO ', - ' vscan YES YES on | off', - ' xattr YES YES on | off', - ' zoned YES YES on | off', - ' userused@... NO NO ', - ' groupused@... NO NO ', - ' userquota@... YES NO | none', - ' groupquota@... YES NO | none', - ' written@ NO NO ', - '', - 'Sizes are specified in bytes with standard units such as K, M, G, etc.', - '', - 'User-defined properties can be specified by using a name containing a colon (:).', - '', - 'The {user|group}{used|quota}@ properties must be appended with', - 'a user or group specifier of one of these forms:', - ' POSIX name (eg: "matt")', - ' POSIX id (eg: "126829")', - ' SMB name@domain (eg: "matt@sun")', - ' SMB SID (eg: "S-1-234-567-89")', - ]), -} -pmap_zfs = { - "origin": { - "edit": False, - "inherit": False, - "values": "", - "type": "str" - }, - "setuid": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "referenced": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "vscan": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "logicalused": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "userrefs": { - "edit": False, - "inherit": False, - "values": "", - "type": "numeric" - }, - "primarycache": { - "edit": True, - "inherit": True, - "values": "all | none | metadata", - "type": "str" - }, - "logbias": { - "edit": True, - "inherit": True, - "values": "latency | throughput", - "type": "str" - }, - "creation": { - "edit": False, - "inherit": False, - "values": "", - "type": "str" - }, - "sync": { - "edit": True, - "inherit": True, - "values": "standard | always | disabled", - "type": "str" - }, - "dedup": { - "edit": True, - "inherit": True, - "values": "on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify", - "type": "bool" - }, - "sharenfs": { - "edit": True, - "inherit": True, - "values": "on | off | share(1m) options", - "type": "bool" - }, - "receive_resume_token": { - "edit": False, - "inherit": False, - "values": "", - "type": "str" - }, - "usedbyrefreservation": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "sharesmb": { - "edit": True, - "inherit": True, - "values": "on | off | sharemgr(1m) options", - "type": "bool" - }, - "rdonly": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "reservation": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "reserv": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "mountpoint": { - "edit": True, - "inherit": True, - "values": " | legacy | none", - "type": "str" - }, - "casesensitivity": { - "edit": False, - "inherit": True, - "values": "sensitive | insensitive | mixed", - "type": "str" - }, - "utf8only": { - "edit": False, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "usedbysnapshots": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "readonly": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "written@": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "avail": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "recsize": { - "edit": True, - "inherit": True, - "values": "512 to 1m, power of 2", - "type": "str" - }, - "atime": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "compression": { - "edit": True, - "inherit": True, - "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", - "type": "bool" - }, - "snapdir": { - "edit": True, - "inherit": True, - "values": "hidden | visible", - "type": "str" - }, - "aclmode": { - "edit": True, - "inherit": True, - "values": "discard | groupmask | passthrough | restricted", - "type": "str" - }, - "zoned": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "copies": { - "edit": True, - "inherit": True, - "values": "1 | 2 | 3", - "type": "numeric" - }, - "snapshot_limit": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "numeric" - }, - "aclinherit": { - "edit": True, - "inherit": True, - "values": "discard | noallow | restricted | passthrough | passthrough-x", - "type": "str" - }, - "compressratio": { - "edit": False, - "inherit": False, - "values": "<1.00x or higher if compressed>", - "type": "str" - }, - "xattr": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "written": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "version": { - "edit": True, - "inherit": False, - "values": "1 | 2 | 3 | 4 | 5 | current", - "type": "numeric" - }, - "recordsize": { - "edit": True, - "inherit": True, - "values": "512 to 1m, power of 2", - "type": "str" - }, - "refquota": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "filesystem_limit": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "numeric" - }, - "lrefer.": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "type": { - "edit": False, - "inherit": False, - "values": "filesystem | volume | snapshot | bookmark", - "type": "str" - }, - "secondarycache": { - "edit": True, - "inherit": True, - "values": "all | none | metadata", - "type": "str" - }, - "refer": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "available": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "used": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "exec": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "compress": { - "edit": True, - "inherit": True, - "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", - "type": "bool" - }, - "volblock": { - "edit": False, - "inherit": True, - "values": "512 to 128k, power of 2", - "type": "str" - }, - "refcompressratio": { - "edit": False, - "inherit": False, - "values": "<1.00x or higher if compressed>", - "type": "str" - }, - "quota": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "groupquota@": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "userquota@": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "snapshot_count": { - "edit": False, - "inherit": False, - "values": "", - "type": "numeric" - }, - "volsize": { - "edit": True, - "inherit": False, - "values": "", - "type": "size" - }, - "clones": { - "edit": False, - "inherit": False, - "values": "[,...]", - "type": "str" - }, - "canmount": { - "edit": True, - "inherit": False, - "values": "on | off | noauto", - "type": "bool" - }, - "mounted": { - "edit": False, - "inherit": False, - "values": "yes | no", - "type": "bool_alt" - }, - "groupused@": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "normalization": { - "edit": False, - "inherit": True, - "values": "none | formc | formd | formkc | formkd", - "type": "str" - }, - "usedbychildren": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "usedbydataset": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "mlslabel": { - "edit": True, - "inherit": True, - "values": "", - "type": "str" - }, - "refreserv": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "defer_destroy": { - "edit": False, - "inherit": False, - "values": "yes | no", - "type": "bool_alt" - }, - "volblocksize": { - "edit": False, - "inherit": True, - "values": "512 to 128k, power of 2", - "type": "str" - }, - "lused.": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "redundant_metadata": { - "edit": True, - "inherit": True, - "values": "all | most", - "type": "str" - }, - "filesystem_count": { - "edit": False, - "inherit": False, - "values": "", - "type": "numeric" - }, - "devices": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "refreservation": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "userused@": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "logicalreferenced": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "checksum": { - "edit": True, - "inherit": True, - "values": "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr", - "type": "bool" - }, - "nbmand": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - } -} - - -def _from_auto(name, value, source='auto'): - ''' - some more complex patching for zfs.from_auto - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.from_auto(name, value, source) - - -def _from_auto_dict(values, source='auto'): - ''' - some more complex patching for zfs.from_auto_dict - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.from_auto_dict(values, source) - - -def _to_auto(name, value, source='auto', convert_to_human=True): - ''' - some more complex patching for zfs.to_auto - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.to_auto(name, value, source, convert_to_human) - - -def _to_auto_dict(values, source='auto', convert_to_human=True): - ''' - some more complex patching for zfs.to_auto_dict - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.to_auto_dict(values, source, convert_to_human) - - -utils_patch = { - 'zfs.is_supported': MagicMock(return_value=True), - 'zfs.has_feature_flags': MagicMock(return_value=True), - 'zfs.property_data_zpool': MagicMock(return_value=pmap_zpool), - 'zfs.property_data_zfs': MagicMock(return_value=pmap_zfs), - # NOTE: we make zpool_command and zfs_command a NOOP - # these are extensively tested in tests.unit.utils.test_zfs - 'zfs.zpool_command': MagicMock(return_value='/bin/false'), - 'zfs.zfs_command': MagicMock(return_value='/bin/false'), - # NOTE: from_auto_dict is a special snowflake - # internally it calls multiple calls from - # salt.utils.zfs but we cannot patch those using - # the common methode, __utils__ is not available - # so they are direct calls, we do some voodoo here. - 'zfs.from_auto_dict': _from_auto_dict, - 'zfs.from_auto': _from_auto, - 'zfs.to_auto_dict': _to_auto_dict, - 'zfs.to_auto': _to_auto, -} - # Skip this test case if we don't have access to mock! @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -890,7 +36,17 @@ class ZfsUtilsTestCase(TestCase): ''' This class contains a set of functions that test salt.utils.zfs utils ''' - ## NOTE: test parameter parsing + def setUp(self): + # property_map mocks + mock_data = ZFSMockData() + self.pmap_zfs = mock_data.pmap_zfs + self.pmap_zpool = mock_data.pmap_zpool + self.pmap_exec_zfs = mock_data.pmap_exec_zfs + self.pmap_exec_zpool = mock_data.pmap_exec_zpool + for name in ('pmap_zfs', 'pmap_zpool', 'pmap_exec_zfs', 'pmap_exec_zpool'): + self.addCleanup(delattr, self, name) + + # NOTE: test parameter parsing def test_is_supported(self): ''' Test zfs.is_supported method @@ -908,8 +64,8 @@ def test_property_data_zpool(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, '_exec', MagicMock(return_value=pmap_exec_zpool)): - self.assertEqual(zfs.property_data_zpool(), pmap_zpool) + with patch.object(zfs, '_exec', MagicMock(return_value=self.pmap_exec_zpool)): + self.assertEqual(zfs.property_data_zpool(), self.pmap_zpool) def test_property_data_zfs(self): ''' @@ -917,10 +73,10 @@ def test_property_data_zfs(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, '_exec', MagicMock(return_value=pmap_exec_zfs)): - self.assertEqual(zfs.property_data_zfs(), pmap_zfs) + with patch.object(zfs, '_exec', MagicMock(return_value=self.pmap_exec_zfs)): + self.assertEqual(zfs.property_data_zfs(), self.pmap_zfs) - ## NOTE: testing from_bool results + # NOTE: testing from_bool results def test_from_bool_on(self): ''' Test from_bool with 'on' @@ -977,7 +133,7 @@ def test_from_bool_alt_passthrough(self): self.assertEqual(zfs.from_bool_alt('passthrough'), 'passthrough') self.assertEqual(zfs.from_bool_alt(zfs.from_bool_alt('passthrough')), 'passthrough') - ## NOTE: testing to_bool results + # NOTE: testing to_bool results def test_to_bool_true(self): ''' Test to_bool with True @@ -1034,7 +190,7 @@ def test_to_bool_alt_passthrough(self): self.assertEqual(zfs.to_bool_alt('passthrough'), 'passthrough') self.assertEqual(zfs.to_bool_alt(zfs.to_bool_alt('passthrough')), 'passthrough') - ## NOTE: testing from_numeric results + # NOTE: testing from_numeric results def test_from_numeric_str(self): ''' Test from_numeric with '42' @@ -1063,7 +219,7 @@ def test_from_numeric_passthrough(self): self.assertEqual(zfs.from_numeric('passthrough'), 'passthrough') self.assertEqual(zfs.from_numeric(zfs.from_numeric('passthrough')), 'passthrough') - ## NOTE: testing to_numeric results + # NOTE: testing to_numeric results def test_to_numeric_str(self): ''' Test to_numeric with '42' @@ -1092,7 +248,7 @@ def test_to_numeric_passthrough(self): self.assertEqual(zfs.to_numeric('passthrough'), 'passthrough') self.assertEqual(zfs.to_numeric(zfs.to_numeric('passthrough')), 'passthrough') - ## NOTE: testing from_size results + # NOTE: testing from_size results def test_from_size_absolute(self): ''' Test from_size with '5G' @@ -1121,7 +277,7 @@ def test_from_size_passthrough(self): self.assertEqual(zfs.from_size('passthrough'), 'passthrough') self.assertEqual(zfs.from_size(zfs.from_size('passthrough')), 'passthrough') - ## NOTE: testing to_size results + # NOTE: testing to_size results def test_to_size_str_absolute(self): ''' Test to_size with '5368709120' @@ -1164,7 +320,7 @@ def test_to_size_passthrough(self): self.assertEqual(zfs.to_size('passthrough'), 'passthrough') self.assertEqual(zfs.to_size(zfs.to_size('passthrough')), 'passthrough') - ## NOTE: testing from_str results + # NOTE: testing from_str results def test_from_str_space(self): ''' Test from_str with "\"my pool/my dataset\" @@ -1200,12 +356,12 @@ def test_from_str_passthrough(self): self.assertEqual(zfs.from_str('passthrough'), 'passthrough') self.assertEqual(zfs.from_str(zfs.from_str('passthrough')), 'passthrough') - ## NOTE: testing to_str results + # NOTE: testing to_str results def test_to_str_space(self): ''' Test to_str with 'my pool/my dataset' ''' - ## NOTE: for fun we use both the '"str"' and "\"str\"" way of getting the literal string: "str" + # NOTE: for fun we use both the '"str"' and "\"str\"" way of getting the literal string: "str" self.assertEqual(zfs.to_str('my pool/my dataset'), '"my pool/my dataset"') self.assertEqual(zfs.to_str(zfs.to_str('my pool/my dataset')), "\"my pool/my dataset\"") @@ -1230,7 +386,7 @@ def test_to_str_passthrough(self): self.assertEqual(zfs.to_str('passthrough'), 'passthrough') self.assertEqual(zfs.to_str(zfs.to_str('passthrough')), 'passthrough') - ## NOTE: testing is_snapshot + # NOTE: testing is_snapshot def test_is_snapshot_snapshot(self): ''' Test is_snapshot with a valid snapshot name @@ -1249,7 +405,7 @@ def test_is_snapshot_filesystem(self): ''' self.assertFalse(zfs.is_snapshot('zpool_name/dataset')) - ## NOTE: testing is_bookmark + # NOTE: testing is_bookmark def test_is_bookmark_snapshot(self): ''' Test is_bookmark with a valid snapshot name @@ -1268,7 +424,7 @@ def test_is_bookmark_filesystem(self): ''' self.assertFalse(zfs.is_bookmark('zpool_name/dataset')) - ## NOTE: testing is_dataset + # NOTE: testing is_dataset def test_is_dataset_snapshot(self): ''' Test is_dataset with a valid snapshot name @@ -1287,15 +443,15 @@ def test_is_dataset_filesystem(self): ''' self.assertTrue(zfs.is_dataset('zpool_name/dataset')) - ## NOTE: testing zfs_command + # NOTE: testing zfs_command def test_zfs_command_simple(self): ''' Test if zfs_command builds the correct string ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zfs_command('list'), "/sbin/zfs list" @@ -1307,8 +463,8 @@ def test_zfs_command_none_target(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zfs_command('list', target=[None, 'mypool', None]), "/sbin/zfs list mypool" @@ -1320,8 +476,8 @@ def test_zfs_command_flag(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1336,8 +492,8 @@ def test_zfs_command_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-t': 'snap', # only list snapshots } @@ -1352,8 +508,8 @@ def test_zfs_command_flag_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1371,8 +527,8 @@ def test_zfs_command_target(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1390,8 +546,8 @@ def test_zfs_command_target_with_space(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1409,8 +565,8 @@ def test_zfs_command_property(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zfs_command('get', property_name='quota', target='mypool'), "/sbin/zfs get quota mypool" @@ -1422,8 +578,8 @@ def test_zfs_command_property_value(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1438,8 +594,8 @@ def test_zfs_command_multi_property_value(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): property_name = ['quota', 'readonly'] property_value = ['5G', 'no'] self.assertEqual( @@ -1453,8 +609,8 @@ def test_zfs_command_fs_props(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-p', # create parent ] @@ -1473,8 +629,8 @@ def test_zfs_command_fs_props_with_space(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_props = { 'quota': '4.2M', 'compression': 'lz4', @@ -1484,15 +640,15 @@ def test_zfs_command_fs_props_with_space(self): '/sbin/zfs create -o compression=lz4 -o quota=4404019 "my pool/jorge\'s dataset"' ) - ## NOTE: testing zpool_command + # NOTE: testing zpool_command def test_zpool_command_simple(self): ''' Test if zfs_command builds the correct string ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zpool_command('list'), "/sbin/zpool list" @@ -1504,8 +660,8 @@ def test_zpool_command_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-o': 'name,size', # show only name and size } @@ -1520,8 +676,8 @@ def test_zpool_command_opt_list(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-d': ['/tmp', '/zvol'], } @@ -1536,8 +692,8 @@ def test_zpool_command_flag_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-o': 'name,size', # show only name and size } @@ -1552,8 +708,8 @@ def test_zpool_command_target(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-o': 'name,size', # show only name and size } @@ -1568,8 +724,8 @@ def test_zpool_command_target_with_space(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): fs_props = { 'quota': '100G', } @@ -1587,8 +743,8 @@ def test_zpool_command_property(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zpool_command('get', property_name='comment', target='mypool'), "/sbin/zpool get comment mypool" @@ -1600,8 +756,8 @@ def test_zpool_command_property_value(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-v', # verbose ] @@ -1616,8 +772,8 @@ def test_parse_command_result_success(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 0 res['stderr'] = '' @@ -1633,8 +789,8 @@ def test_parse_command_result_success_nolabel(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 0 res['stderr'] = '' @@ -1650,8 +806,8 @@ def test_parse_command_result_fail(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = '' @@ -1667,8 +823,8 @@ def test_parse_command_result_nolabel(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = '' @@ -1684,8 +840,8 @@ def test_parse_command_result_fail_message(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = "\n".join([ @@ -1705,8 +861,8 @@ def test_parse_command_result_fail_message_nolabel(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = "\n".join([ @@ -1719,5 +875,3 @@ def test_parse_command_result_fail_message_nolabel(self): zfs.parse_command_result(res), OrderedDict([('error', 'ice is not hot')]), ) - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4