diff --git a/Jenkinsfile b/Jenkinsfile index 7f8400660..fd3a4511d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -111,13 +111,132 @@ pipeline { name: "Python", steps: this ) - def mapPatallelTasks = pythonTasksGen.generateParallelTests() - parallel(mapPatallelTasks) + //def mapPatallelTasks = pythonTasksGen.generateParallelTests() + //parallel(mapPatallelTasks) } } } } } + stage('Parallel Windows Tests') { + parallel { + stage('Windows Py 2.7.16') { + agent { label 'windows-2019-immutable' } + options { skipDefaultCheckout() } + environment { + PATH = "C:\\Windows\\System32;${env.PATH}"; + } + steps { + withGithubNotify(context: 'Test', tab: 'tests') { + deleteDir() + unstash "source" + dir("${BASE_DIR}") { + bat label: 'Execute Tests', script: ".\\tests\\scripts\\configure_windows_instance.bat 2.7.16 python27" + /* + bat label: 'Install Chocolatey', script: ".\\tests\\scripts\\install_chocolatey.bat" + bat label: 'Uninstall Python3', script: "choco uninstall python3" + bat label: 'Install Modules', script: ".\\tests\\scripts\\download_json_schema.bat" + bat label: 'Install Modules', script: ".\\tests\\scripts\\install_modules.bat python" + bat label: 'Execute Tests', script: "pytest" + */ + } + } + } + } + stage('Windows Py 3.5.4') { + agent { label 'windows-2019-immutable' } + options { skipDefaultCheckout() } + environment { + PATH = "C:\\Windows\\System32;${env.PATH}"; + } + steps { + withGithubNotify(context: 'Test', tab: 'tests') { + deleteDir() + unstash "source" + dir("${BASE_DIR}") { + bat label: 'Execute Tests', script: ".\\tests\\scripts\\configure_windows_instance.bat 3.5.4 python35" + /* + bat label: 'Install Chocolatey', script: ".\\tests\\scripts\\install_chocolatey.bat" + bat label: 'Install Python3.5', script: "./tests/scripts/install_python.bat 3.5.4" + bat label: 'Install Modules', script: "./tests/scripts/download_json_schema.bat" + bat label: 'Install Modules', script: "./tests/scripts/install_modules.bat py" + bat label: 'Execute Tests', script: "pytest" + */ + } + } + } + } + stage('Windows Py 3.6.7') { + agent { label 'windows-2019-immutable' } + options { skipDefaultCheckout() } + environment { + PATH = "C:\\Windows\\System32;${env.PATH}"; + } + steps { + withGithubNotify(context: 'Test', tab: 'tests') { + deleteDir() + unstash "source" + dir("${BASE_DIR}") { + bat label: 'Execute Tests', script: ".\\tests\\scripts\\configure_windows_instance.bat 3.6.7 python36" + /* + bat label: 'Install Chocolatey', script: ".\\tests\\scripts\\install_chocolatey.bat" + bat label: 'Install Python3.6', script: "./tests/scripts/install_python.bat 3.6.7" + bat label: 'Install Modules', script: "./tests/scripts/download_json_schema.bat" + bat label: 'Install Modules', script: "./tests/scripts/install_modules.bat py" + bat label: 'Execute Tests', script: "pytest" + */ + } + } + } + } + stage('Windows Py 3.7.2') { + agent { label 'windows-2019-immutable' } + options { skipDefaultCheckout() } + environment { + PATH = "C:\\Windows\\System32;${env.PATH}"; + } + steps { + withGithubNotify(context: 'Test', tab: 'tests') { + deleteDir() + unstash "source" + dir("${BASE_DIR}") { + bat label: 'Execute Tests', script: ".\\tests\\scripts\\configure_windows_instance.bat 3.7.2 py" + /* + bat label: 'Install Chocolatey', script: ".\\tests\\scripts\\install_chocolatey.bat" + bat label: 'Install Python3.7', script: "./tests/scripts/install_python.bat 3.7.2" + bat label: 'Install Modules', script: "./tests/scripts/download_json_schema.bat" + bat label: 'Install Modules', script: "./tests/scripts/install_modules.bat py" + bat label: 'Execute Tests', script: "pytest" + */ + } + } + } + } + stage('Windows Py 3.8.1') { + agent { label 'windows-2019-immutable' } + options { skipDefaultCheckout() } + environment { + PATH = "C:\\Windows\\System32;${env.PATH}"; + } + steps { + withGithubNotify(context: 'Test', tab: 'tests') { + deleteDir() + unstash "source" + dir("${BASE_DIR}") { + bat label: 'Execute Tests', script: ".\\tests\\scripts\\configure_windows_instance.bat 3.8.1 python38" + /* + bat label: 'Install Chocolatey', script: ".\\tests\\scripts\\install_chocolatey.bat" + bat label: 'Install Python3.7', script: "./tests/scripts/install_python.bat 3.8.1" + bat label: 'Install Modules', script: "./tests/scripts/download_json_schema.bat" + bat label: 'Install Modules', script: "./tests/scripts/install_modules.bat py" + bat label: 'Execute Tests', script: "pytest" + */ + } + } + } + } + } + } stage('Building packages') { options { skipDefaultCheckout() } when { diff --git a/tests/scripts/configure_windows_instance.bat b/tests/scripts/configure_windows_instance.bat new file mode 100644 index 000000000..2842eaaa7 --- /dev/null +++ b/tests/scripts/configure_windows_instance.bat @@ -0,0 +1,8 @@ +.\tests\scripts\install_chocolatey.bat^ + && refreshenv^ + && .\tests\scripts\install_python.bat %1 %2^ + && refreshenv^ + && %2 -m pip install -r .\tests\requirements\requirements-base.txt^ + && .\tests\scripts\download_json_schema.bat^ + && .\tests\scripts\download_gherkin_features.bat^ + && .\tests\scripts\execute_pytest_windows.bat %1 %2 \ No newline at end of file diff --git a/tests/scripts/download_gherkin_features.bat b/tests/scripts/download_gherkin_features.bat new file mode 100644 index 000000000..309d7e4eb --- /dev/null +++ b/tests/scripts/download_gherkin_features.bat @@ -0,0 +1,6 @@ +mkdir .\tests\tempFeatures +curl https://codeload.github.com/elastic/apm/zip/master -o .\tests\tempFeatures\features.zip +7z x .\tests\tempFeatures\features.zip -o.\tests\tempFeatures *.feature -y -r +mkdir .\tests\bdd\features +xcopy .\tests\tempFeatures\apm-master\tests\agents\gherkin-specs\* .\tests\bdd\features /Y /S +del .\tests\tempFeatures\ /F /Q /S \ No newline at end of file diff --git a/tests/scripts/download_json_schema.bat b/tests/scripts/download_json_schema.bat new file mode 100644 index 000000000..1bfabac69 --- /dev/null +++ b/tests/scripts/download_json_schema.bat @@ -0,0 +1,6 @@ +mkdir .\tests\tempSchema +curl https://codeload.github.com/elastic/apm-server/zip/master -o .\tests\tempSchema\master.zip +7z x .\tests\tempSchema\master.zip -o.\tests\tempSchema *.json -y -r +mkdir .\tests\.schemacache +xcopy .\tests\tempSchema\apm-server-master\docs\spec\* .\tests\.schemacache /Y /S +del .\tests\tempSchema\ /F /Q /S \ No newline at end of file diff --git a/tests/scripts/execute_pytest_windows.bat b/tests/scripts/execute_pytest_windows.bat new file mode 100644 index 000000000..0d8758165 --- /dev/null +++ b/tests/scripts/execute_pytest_windows.bat @@ -0,0 +1,7 @@ +SETLOCAL EnableDelayedExpansion +set pythonVersion=%1 +set pythonExecutable=%2 +set majorVersion=!pythonVersion:~0,1! +set minorVersion=!pythonVersion:~2,1! +if %majorVersion% EQU 2 (set pyArgs=--ignore-glob="*/py3_*.py" --ignore-glob="*/asyncio/*") else ( if %minorVersion% EQU 5 (set pyArgs=--ignore-glob="*/asyncio/*")) +%pythonExecutable% -m pytest --cov --cov-report xml:coverage.xml %pyArgs% \ No newline at end of file diff --git a/tests/scripts/install_chocolatey.bat b/tests/scripts/install_chocolatey.bat new file mode 100644 index 000000000..ac948a4bc --- /dev/null +++ b/tests/scripts/install_chocolatey.bat @@ -0,0 +1 @@ +@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" \ No newline at end of file diff --git a/tests/scripts/install_modules.bat b/tests/scripts/install_modules.bat new file mode 100644 index 000000000..44adebf19 --- /dev/null +++ b/tests/scripts/install_modules.bat @@ -0,0 +1,7 @@ +SETLOCAL EnableDelayedExpansion +set pythonVersion=%1 +set pythonExecutable=%2 +set majorVersion=!pythonVersion:~0,1! +echo !majorVersion! +if %majorVersion% EQU 2 (!pythonExecutable! -m pip install -r .\tests\requirements\requirements-base.txt) else (!pythonExecutable! -m pip install -r .\tests\requirements\requirements-base.txt) +SETLOCAL DisableDelayedExpansion \ No newline at end of file diff --git a/tests/scripts/install_python.bat b/tests/scripts/install_python.bat new file mode 100644 index 000000000..5da019983 --- /dev/null +++ b/tests/scripts/install_python.bat @@ -0,0 +1,9 @@ +SETLOCAL EnableDelayedExpansion +set pythonVersion=%1 +set pythonExecutable=%2 +set majorVersion=!pythonVersion:~0,1! +set minorVersion=!pythonVersion:~2,1! +if %majorVersion% EQU 3 (choco install python3 --version=%1 -y --force --allow-downgrade) else (choco install python2 -y --force) +if %majorVersion% EQU 3 ( if %minorVersion% NEQ 7 (move c:\%pythonExecutable%\python.exe c:\%pythonExecutable%\%pythonExecutable%.exe)) else (move c:\%pythonExecutable%\python.exe c:\%pythonExecutable%\%pythonExecutable%.exe) +SETLOCAL DisableDelayedExpansion +