#!groovy def initializeEnvironment() { env.DRIVER_DISPLAY_NAME = 'Cassandra Python Driver' env.DRIVER_METRIC_TYPE = 'oss' if (env.GIT_URL.contains('riptano/python-driver')) { env.DRIVER_DISPLAY_NAME = 'private ' + env.DRIVER_DISPLAY_NAME env.DRIVER_METRIC_TYPE = 'oss-private' } else if (env.GIT_URL.contains('python-dse-driver')) { env.DRIVER_DISPLAY_NAME = 'DSE Python Driver' env.DRIVER_METRIC_TYPE = 'dse' } env.GIT_SHA = "${env.GIT_COMMIT.take(7)}" env.GITHUB_PROJECT_URL = "https://${GIT_URL.replaceFirst(/(git@|http:\/\/|https:\/\/)/, '').replace(':', '/').replace('.git', '')}" env.GITHUB_BRANCH_URL = "${GITHUB_PROJECT_URL}/tree/${env.BRANCH_NAME}" env.GITHUB_COMMIT_URL = "${GITHUB_PROJECT_URL}/commit/${env.GIT_COMMIT}" sh label: 'Assign Python global environment', script: '''#!/bin/bash -lex pyenv global ${PYTHON_VERSION} ''' sh label: 'Install socat; required for unix socket tests', script: '''#!/bin/bash -lex sudo apt-get install socat ''' sh label: 'Install the latest setuptools', script: '''#!/bin/bash -lex pip install --upgrade pip pip install -U setuptools ''' sh label: 'Install CCM', script: '''#!/bin/bash -lex pip install ${HOME}/ccm ''' // Determine if server version is Apache Cassandra� or DataStax Enterprise if (env.CASSANDRA_VERSION.split('-')[0] == 'dse') { sh label: 'Install DataStax Enterprise requirements', script: '''#!/bin/bash -lex pip install -r test-datastax-requirements.txt ''' } else { sh label: 'Install Apache CassandraⓇ requirements', script: '''#!/bin/bash -lex pip install -r test-requirements.txt ''' sh label: 'Uninstall the geomet dependency since it is not required for Cassandra', script: '''#!/bin/bash -lex pip uninstall -y geomet ''' } sh label: 'Install unit test modules', script: '''#!/bin/bash -lex pip install nose-ignore-docstring nose-exclude service_identity ''' if (env.CYTHON_ENABLED == 'True') { sh label: 'Install cython modules', script: '''#!/bin/bash -lex pip install cython numpy ''' } sh label: 'Download Apache CassandraⓇ or DataStax Enterprise', script: '''#!/bin/bash -lex . ${CCM_ENVIRONMENT_SHELL} ${CASSANDRA_VERSION} ''' sh label: 'Display Python and environment information', script: '''#!/bin/bash -le # Load CCM environment variables set -o allexport . ${HOME}/environment.txt set +o allexport python --version pip --version printenv | sort ''' } def installDriverAndCompileExtensions() { if (env.CYTHON_ENABLED == 'True') { sh label: 'Install the driver and compile with C extensions with Cython', script: '''#!/bin/bash -lex python setup.py build_ext --inplace ''' } else { sh label: 'Install the driver and compile with C extensions without Cython', script: '''#!/bin/bash -lex python setup.py build_ext --inplace --no-cython ''' } } def executeStandardTests() { sh label: 'Execute unit tests', script: '''#!/bin/bash -lex # Load CCM environment variables set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=unit_results.xml tests/unit/ || true EVENT_LOOP_MANAGER=eventlet VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=unit_eventlet_results.xml tests/unit/io/test_eventletreactor.py || true EVENT_LOOP_MANAGER=gevent VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=unit_gevent_results.xml tests/unit/io/test_geventreactor.py || true ''' sh label: 'Execute Simulacron integration tests', script: '''#!/bin/bash -lex # Load CCM environment variables set -o allexport . ${HOME}/environment.txt set +o allexport SIMULACRON_JAR="${HOME}/simulacron.jar" SIMULACRON_JAR=${SIMULACRON_JAR} EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CASSANDRA_DIR=${CCM_INSTALL_DIR} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --exclude test_backpressure.py --xunit-file=simulacron_results.xml tests/integration/simulacron/ || true # Run backpressure tests separately to avoid memory issue SIMULACRON_JAR=${SIMULACRON_JAR} EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CASSANDRA_DIR=${CCM_INSTALL_DIR} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --exclude test_backpressure.py --xunit-file=simulacron_backpressure_1_results.xml tests/integration/simulacron/test_backpressure.py:TCPBackpressureTests.test_paused_connections || true SIMULACRON_JAR=${SIMULACRON_JAR} EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CASSANDRA_DIR=${CCM_INSTALL_DIR} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --exclude test_backpressure.py --xunit-file=simulacron_backpressure_2_results.xml tests/integration/simulacron/test_backpressure.py:TCPBackpressureTests.test_queued_requests_timeout || true SIMULACRON_JAR=${SIMULACRON_JAR} EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CASSANDRA_DIR=${CCM_INSTALL_DIR} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --exclude test_backpressure.py --xunit-file=simulacron_backpressure_3_results.xml tests/integration/simulacron/test_backpressure.py:TCPBackpressureTests.test_cluster_busy || true SIMULACRON_JAR=${SIMULACRON_JAR} EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CASSANDRA_DIR=${CCM_INSTALL_DIR} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --exclude test_backpressure.py --xunit-file=simulacron_backpressure_4_results.xml tests/integration/simulacron/test_backpressure.py:TCPBackpressureTests.test_node_busy || true ''' sh label: 'Execute CQL engine integration tests', script: '''#!/bin/bash -lex # Load CCM environment variables set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=cqle_results.xml tests/integration/cqlengine/ || true ''' sh label: 'Execute Apache CassandraⓇ integration tests', script: '''#!/bin/bash -lex # Load CCM environment variables set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml tests/integration/standard/ || true ''' if (env.CASSANDRA_VERSION.split('-')[0] == 'dse' && env.CASSANDRA_VERSION.split('-')[1] != '4.8') { sh label: 'Execute DataStax Enterprise integration tests', script: '''#!/bin/bash -lex # Load CCM environment variable set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CASSANDRA_DIR=${CCM_INSTALL_DIR} DSE_VERSION=${DSE_VERSION} ADS_HOME="${HOME}/" VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=dse_results.xml tests/integration/advanced/ || true ''' } sh label: 'Execute DataStax Constellation integration tests', script: '''#!/bin/bash -lex # Load CCM environment variable set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CLOUD_PROXY_PATH="${HOME}/proxy/" CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=advanced_results.xml tests/integration/cloud/ || true ''' if (env.EXECUTE_LONG_TESTS == 'True') { sh label: 'Execute long running integration tests', script: '''#!/bin/bash -lex # Load CCM environment variable set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --exclude-dir=tests/integration/long/upgrade --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true ''' } } def executeDseSmokeTests() { sh label: 'Execute profile DataStax Enterprise smoke test integration tests', script: '''#!/bin/bash -lex # Load CCM environment variable set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CCM_ARGS="${CCM_ARGS}" CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} DSE_VERSION=${DSE_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml tests/integration/standard/test_dse.py || true ''' } def executeEventLoopTests() { sh label: 'Execute profile event loop manager integration tests', script: '''#!/bin/bash -lex # Load CCM environment variable set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_TESTS=( "tests/integration/standard/test_cluster.py" "tests/integration/standard/test_concurrent.py" "tests/integration/standard/test_connection.py" "tests/integration/standard/test_control_connection.py" "tests/integration/standard/test_metrics.py" "tests/integration/standard/test_query.py" "tests/integration/simulacron/test_endpoint.py" "tests/integration/long/test_ssl.py" ) EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} CCM_ARGS="${CCM_ARGS}" DSE_VERSION=${DSE_VERSION} CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION} MAPPED_CASSANDRA_VERSION=${MAPPED_CASSANDRA_VERSION} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml ${EVENT_LOOP_TESTS[@]} || true ''' } def executeUpgradeTests() { sh label: 'Execute profile upgrade integration tests', script: '''#!/bin/bash -lex # Load CCM environment variable set -o allexport . ${HOME}/environment.txt set +o allexport EVENT_LOOP_MANAGER=${EVENT_LOOP_MANAGER} VERIFY_CYTHON=${CYTHON_ENABLED} nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=upgrade_results.xml tests/integration/upgrade || true ''' } def executeTests() { switch(params.PROFILE) { case 'DSE-SMOKE-TEST': executeDseSmokeTests() break case 'EVENT-LOOP': executeEventLoopTests() break case 'UPGRADE': executeUpgradeTests() break default: executeStandardTests() break } } def notifySlack(status = 'started') { // Set the global pipeline scoped environment (this is above each matrix) env.BUILD_STATED_SLACK_NOTIFIED = 'true' def buildType = 'Commit' if (params.CI_SCHEDULE != 'DO-NOT-CHANGE-THIS-SELECTION') { buildType = "${params.CI_SCHEDULE.toLowerCase().capitalize()}" } def color = 'good' // Green if (status.equalsIgnoreCase('aborted')) { color = '808080' // Grey } else if (status.equalsIgnoreCase('unstable')) { color = 'warning' // Orange } else if (status.equalsIgnoreCase('failed')) { color = 'danger' // Red } def message = """Build ${status} for ${env.DRIVER_DISPLAY_NAME} [${buildType}] <${env.GITHUB_BRANCH_URL}|${env.BRANCH_NAME}> - <${env.RUN_DISPLAY_URL}|#${env.BUILD_NUMBER}> - <${env.GITHUB_COMMIT_URL}|${env.GIT_SHA}>""" if (params.CI_SCHEDULE != 'DO-NOT-CHANGE-THIS-SELECTION') { message += " - ${params.CI_SCHEDULE_PYTHON_VERSION} - ${params.EVENT_LOOP_MANAGER}" } if (!status.equalsIgnoreCase('Started')) { message += """ ${status} after ${currentBuild.durationString - ' and counting'}""" } slackSend color: "${color}", channel: "#python-driver-dev-bots", message: "${message}" } def submitCIMetrics(buildType) { long durationMs = currentBuild.duration long durationSec = durationMs / 1000 long nowSec = (currentBuild.startTimeInMillis + durationMs) / 1000 def branchNameNoPeriods = env.BRANCH_NAME.replaceAll('\\.', '_') def durationMetric = "okr.ci.python.${env.DRIVER_METRIC_TYPE}.${buildType}.${branchNameNoPeriods} ${durationSec} ${nowSec}" timeout(time: 1, unit: 'MINUTES') { withCredentials([string(credentialsId: 'lab-grafana-address', variable: 'LAB_GRAFANA_ADDRESS'), string(credentialsId: 'lab-grafana-port', variable: 'LAB_GRAFANA_PORT')]) { withEnv(["DURATION_METRIC=${durationMetric}"]) { sh label: 'Send runtime metrics to labgrafana', script: '''#!/bin/bash -lex echo "${DURATION_METRIC}" | nc -q 5 ${LAB_GRAFANA_ADDRESS} ${LAB_GRAFANA_PORT} ''' } } } } def describePerCommitStage() { script { def type = 'standard' def serverDescription = 'current Apache CassandaraⓇ and supported DataStax Enterprise versions' if (env.BRANCH_NAME ==~ /long-python.*/) { type = 'long' } else if (env.BRANCH_NAME ==~ /dev-python.*/) { type = 'dev' } currentBuild.displayName = "Per-Commit (${env.EVENT_LOOP_MANAGER} | ${type.capitalize()})" currentBuild.description = "Per-Commit build and ${type} testing of ${serverDescription} against Python v2.7.18 and v3.5.9 using ${env.EVENT_LOOP_MANAGER} event loop manager" } sh label: 'Describe the python environment', script: '''#!/bin/bash -lex python -V pip freeze ''' } def describeScheduledTestingStage() { script { def type = params.CI_SCHEDULE.toLowerCase().capitalize() def displayName = "${type} schedule (${env.EVENT_LOOP_MANAGER}" if (env.CYTHON_ENABLED == 'True') { displayName += " | Cython" } if (params.PROFILE != 'NONE') { displayName += " | ${params.PROFILE}" } displayName += ")" currentBuild.displayName = displayName def serverVersionDescription = "${params.CI_SCHEDULE_SERVER_VERSION.replaceAll(' ', ', ')} server version(s) in the matrix" def pythonVersionDescription = "${params.CI_SCHEDULE_PYTHON_VERSION.replaceAll(' ', ', ')} Python version(s) in the matrix" def description = "${type} scheduled testing using ${env.EVENT_LOOP_MANAGER} event loop manager" if (env.CYTHON_ENABLED == 'True') { description += ", with Cython enabled" } if (params.PROFILE != 'NONE') { description += ", ${params.PROFILE} profile" } description += ", ${serverVersionDescription}, and ${pythonVersionDescription}" currentBuild.description = description } } def describeAdhocTestingStage() { script { def serverType = params.ADHOC_BUILD_AND_EXECUTE_TESTS_SERVER_VERSION.split('-')[0] def serverDisplayName = 'Apache CassandaraⓇ' def serverVersion = " v${serverType}" if (serverType == 'ALL') { serverDisplayName = "all ${serverDisplayName} and DataStax Enterprise server versions" serverVersion = '' } else { try { serverVersion = " v${env.ADHOC_BUILD_AND_EXECUTE_TESTS_SERVER_VERSION.split('-')[1]}" } catch (e) { ;; // no-op } if (serverType == 'dse') { serverDisplayName = 'DataStax Enterprise' } } def displayName = "${params.ADHOC_BUILD_AND_EXECUTE_TESTS_SERVER_VERSION} for v${params.ADHOC_BUILD_AND_EXECUTE_TESTS_PYTHON_VERSION} (${env.EVENT_LOOP_MANAGER}" if (env.CYTHON_ENABLED == 'True') { displayName += " | Cython" } if (params.PROFILE != 'NONE') { displayName += " | ${params.PROFILE}" } displayName += ")" currentBuild.displayName = displayName def description = "Testing ${serverDisplayName} ${serverVersion} using ${env.EVENT_LOOP_MANAGER} against Python ${params.ADHOC_BUILD_AND_EXECUTE_TESTS_PYTHON_VERSION}" if (env.CYTHON_ENABLED == 'True') { description += ", with Cython" } if (params.PROFILE == 'NONE') { if (params.EXECUTE_LONG_TESTS) { description += ", with" } else { description += ", without" } description += " long tests executed" } else { description += ", ${params.PROFILE} profile" } currentBuild.description = description } } def branchPatternCron = ~"(master)" def riptanoPatternCron = ~"(riptano)" pipeline { agent none // Global pipeline timeout options { timeout(time: 10, unit: 'HOURS') buildDiscarder(logRotator(artifactNumToKeepStr: '10', // Keep only the last 10 artifacts numToKeepStr: '50')) // Keep only the last 50 build records } parameters { choice( name: 'ADHOC_BUILD_TYPE', choices: ['BUILD', 'BUILD-AND-EXECUTE-TESTS'], description: '''
Perform a adhoc build operation
| Choice | Description |
|---|---|
| BUILD | Performs a Per-Commit build |
| BUILD-AND-EXECUTE-TESTS | Performs a build and executes the integration and unit tests |
| Choice | Description |
|---|---|
| 2.1 | Apache CassandaraⓇ; v2.1.x |
| 2.2 | Apache CassandarⓇ; v2.2.x |
| 3.0 | Apache CassandaraⓇ v3.0.x |
| 3.11 | Apache CassandaraⓇ v3.11.x |
| 4.0 | Apache CassandaraⓇ v4.x (CURRENTLY UNDER DEVELOPMENT) |
| dse-5.0 | DataStax Enterprise v5.0.x (Long Term Support) |
| dse-5.1 | DataStax Enterprise v5.1.x |
| dse-6.0 | DataStax Enterprise v6.0.x |
| dse-6.7 | DataStax Enterprise v6.7.x |
| dse-6.8 | DataStax Enterprise v6.8.x (CURRENTLY UNDER DEVELOPMENT) |
Event loop manager to utilize for scheduled or adhoc builds
| Choice | Description |
|---|---|
| LIBEV | A full-featured and high-performance event loop that is loosely modeled after libevent, but without its limitations and bugs |
| GEVENT | A co-routine -based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev or libuv event loop |
| EVENTLET | A concurrent networking library for Python that allows you to change how you run your code, not how you write it |
| ASYNCIO | A library to write concurrent code using the async/await syntax |
| ASYNCORE | A module provides the basic infrastructure for writing asynchronous socket service clients and servers |
| TWISTED | An event-driven networking engine written in Python and licensed under the open source MIT license |
Profile to utilize for scheduled or adhoc builds
| Choice | Description |
|---|---|
| NONE | Execute the standard tests for the driver |
| DSE-SMOKE-TEST | Execute only the DataStax Enterprise smoke tests |
| EVENT-LOOP | Execute only the event loop tests for the specified event loop manager (see: EVENT_LOOP_MANAGER) |
| UPGRADE | Execute only the upgrade tests |