This is an automated email from the ASF dual-hosted git repository. adelapena pushed a commit to branch cassandra-3.11 in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 7694cc51739247243bd457a9d97d16b608207593 Merge: 54f7308 269bc5c Author: Andrés de la Peña <[email protected]> AuthorDate: Thu May 27 16:32:01 2021 +0100 Merge branch 'cassandra-3.0' into cassandra-3.11 .circleci/config-2_1.yml | 178 +++++-- .circleci/config.yml | 995 ++++++++++++++++++++++++++----------- .circleci/config.yml.HIGHRES | 995 ++++++++++++++++++++++++++----------- .circleci/config.yml.LOWRES | 995 ++++++++++++++++++++++++++----------- doc/source/development/testing.rst | 113 +++-- 5 files changed, 2313 insertions(+), 963 deletions(-) diff --cc .circleci/config-2_1.yml index 48b1858,03e4ae9..efe9052 --- a/.circleci/config-2_1.yml +++ b/.circleci/config-2_1.yml @@@ -115,14 -138,7 +138,14 @@@ with_dtests_jobs: &with_dtest_job - utests_compression: requires: - start_utests_compression + - start_utests_stress: + type: approval + requires: + - build + - utests_stress: + requires: + - start_utests_stress - - start_jvm_upgrade_dtest: + - start_j8_dtest_jars_build: type: approval - j8_dtest_jars_build: requires: diff --cc .circleci/config.yml index ff7e3bf,c87c848..1451eea --- a/.circleci/config.yml +++ b/.circleci/config.yml @@@ -382,117 -817,16 +817,78 @@@ jobs - REPEATED_DTEST_VNODES: false - REPEATED_DTEST_COUNT: 100 - REPEATED_DTEST_STOP_ON_FAILURE: false + - REPEATED_UPGRADE_DTEST_NAME: null + - REPEATED_UPGRADE_DTEST_COUNT: 100 + - REPEATED_UPGRADE_DTEST_STOP_ON_FAILURE: false + - REPEATED_JVM_UPGRADE_DTEST_CLASS: null + - REPEATED_JVM_UPGRADE_DTEST_METHODS: null + - REPEATED_JVM_UPGRADE_DTEST_COUNT: 100 + - REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE: false - JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - JDK_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - j8_repeated-dtest: ++ utests_stress: + docker: + - image: apache/cassandra-testing-ubuntu2004-java11-w-dependencies:20210304 + resource_class: medium + working_directory: ~/ + shell: /bin/bash -eo pipefail -l - parallelism: 4 ++ parallelism: 1 + steps: + - attach_workspace: + at: /home/cassandra + - run: - name: Clone Cassandra dtest Repository (via git) - command: | - git clone --single-branch --branch $DTEST_BRANCH --depth 1 $DTEST_REPO ~/cassandra-dtest - - run: - name: Configure virtualenv and python Dependencies ++ name: Run Unit Tests (stress-test) + command: | - # note, this should be super quick as all dependencies should be pre-installed in the docker image - # if additional dependencies were added to requirmeents.txt and the docker image hasn't been updated - # we'd have to install it here at runtime -- which will make things slow, so do yourself a favor and - # rebuild the docker image! (it automatically pulls the latest requirements.txt on build) - source ~/env3.6/bin/activate + export PATH=$JAVA_HOME/bin:$PATH - pip3 install --upgrade -r ~/cassandra-dtest/requirements.txt - pip3 freeze - - run: - name: Run repeated dtest - no_output_timeout: 15m - command: | - if [ "$REPEATED_DTEST_NAME" == "<nil>" ]; then - echo "Repeated dtest name hasn't been defined, exiting without running any test" - elif [ "$REPEATED_DTEST_COUNT" == "<nil>" ]; then - echo "Repeated dtest count hasn't been defined, exiting without running any test" - elif [ "$REPEATED_DTEST_COUNT" -le 0 ]; then - echo "Repeated dtest count is lesser or equals than zero, exiting without running any test" - else - - # Calculate the number of test iterations to be run by the current parallel runner. - # Since we are running the same test multiple times there is no need to use `circleci tests split`. - count=$((REPEATED_DTEST_COUNT / CIRCLE_NODE_TOTAL)) - if (($CIRCLE_NODE_INDEX < (REPEATED_DTEST_COUNT % CIRCLE_NODE_TOTAL))); then - count=$((count+1)) - fi - - if (($count <= 0)); then - echo "No tests to run in this runner" - else - echo "Running $REPEATED_DTEST_NAME $count times" - - source ~/env3.6/bin/activate - export PATH=$JAVA_HOME/bin:$PATH - - java -version - cd ~/cassandra-dtest - mkdir -p /tmp/dtest - - echo "env: $(env)" - echo "** done env" - mkdir -p /tmp/results/dtests - - stop_on_failure_arg="" - if $REPEATED_UTEST_STOP_ON_FAILURE; then - stop_on_failure_arg="-x" - fi - - vnodes_args="" - if $REPEATED_DTEST_VNODES; then - vnodes_args="--use-vnodes --num-tokens=16" - fi - - # we need the "set -o pipefail" here so that the exit code that circleci will actually use is from pytest and not the exit code from tee - set -o pipefail && cd ~/cassandra-dtest && pytest $vnodes_args --count=$count $stop_on_failure_arg --log-cli-level=DEBUG --junit-xml=/tmp/results/dtests/pytest_result.xml -s --cassandra-dir=/home/cassandra/cassandra --keep-test-dir $REPEATED_DTEST_NAME | tee /tmp/dtest/stdout.txt - fi ++ time mv ~/cassandra /tmp ++ cd /tmp/cassandra ++ if [ -d ~/dtest_jars ]; then ++ cp ~/dtest_jars/dtest* /tmp/cassandra/build/ + fi ++ ant stress-test -Dtest.classlistfile=/tmp/java_tests_${CIRCLE_NODE_INDEX}_final.txt -Dtest.classlistprefix=unit ++ no_output_timeout: 15m + - store_test_results: - path: /tmp/results ++ path: /tmp/cassandra/build/test/output/ + - store_artifacts: - path: /tmp/dtest - destination: dtest ++ path: /tmp/cassandra/build/test/output ++ destination: junitxml + - store_artifacts: - path: ~/cassandra-dtest/logs - destination: dtest_logs ++ path: /tmp/cassandra/build/test/logs ++ destination: logs + environment: + - JAVA8_HOME: /usr/lib/jvm/java-8-openjdk-amd64 + - ANT_HOME: /usr/share/ant + - LANG: en_US.UTF-8 + - KEEP_TEST_DIR: true + - DEFAULT_DIR: /home/cassandra/cassandra-dtest + - PYTHONIOENCODING: utf-8 + - PYTHONUNBUFFERED: true + - CASS_DRIVER_NO_EXTENSIONS: true + - CASS_DRIVER_NO_CYTHON: true + - CASSANDRA_SKIP_SYNC: true + - DTEST_REPO: git://github.com/apache/cassandra-dtest.git + - DTEST_BRANCH: trunk + - CCM_MAX_HEAP_SIZE: 1024M + - CCM_HEAP_NEWSIZE: 256M + - REPEATED_UTEST_TARGET: testsome + - REPEATED_UTEST_CLASS: null + - REPEATED_UTEST_METHODS: null + - REPEATED_UTEST_COUNT: 100 + - REPEATED_UTEST_STOP_ON_FAILURE: false + - REPEATED_DTEST_NAME: null + - REPEATED_DTEST_VNODES: false + - REPEATED_DTEST_COUNT: 100 + - REPEATED_DTEST_STOP_ON_FAILURE: false ++ - REPEATED_UPGRADE_DTEST_NAME: null ++ - REPEATED_UPGRADE_DTEST_COUNT: 100 ++ - REPEATED_UPGRADE_DTEST_STOP_ON_FAILURE: false ++ - REPEATED_JVM_UPGRADE_DTEST_CLASS: null ++ - REPEATED_JVM_UPGRADE_DTEST_METHODS: null ++ - REPEATED_JVM_UPGRADE_DTEST_COUNT: 100 ++ - REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE: false + - JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64 + - JDK_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - utests_stress: + j8_unit_tests: docker: - image: apache/cassandra-testing-ubuntu2004-java11-w-dependencies:20210304 resource_class: medium @@@ -659,36 -1127,24 +1189,24 @@@ - attach_workspace: at: /home/cassandra - run: - name: Clone Cassandra dtest Repository (via git) - command: | - git clone --single-branch --branch $DTEST_BRANCH --depth 1 $DTEST_REPO ~/cassandra-dtest - - run: - name: Configure virtualenv and python Dependencies + name: Run Unit Tests (long-test) command: | - # note, this should be super quick as all dependencies should be pre-installed in the docker image - # if additional dependencies were added to requirmeents.txt and the docker image hasn't been updated - # we'd have to install it here at runtime -- which will make things slow, so do yourself a favor and - # rebuild the docker image! (it automatically pulls the latest requirements.txt on build) - source ~/env3.6/bin/activate export PATH=$JAVA_HOME/bin:$PATH - pip3 install --upgrade -r ~/cassandra-dtest/requirements.txt - pip3 freeze - - run: - name: Determine Tests to Run (j8_with_vnodes) - no_output_timeout: 5m - command: "# reminder: this code (along with all the steps) is independently executed on every circle container\n# so the goal here is to get the circleci script to return the tests *this* container will run\n# which we do via the `circleci` cli tool.\n\ncd cassandra-dtest\nsource ~/env3.6/bin/activate\nexport PATH=$JAVA_HOME/bin:$PATH\n\nif [ -n '' ]; then\n export \nfi\n\necho \"***Collected DTests (j8_with_vnodes)***\"\nset -eo pipefail && ./run_dtests.py --use-vnodes --skip- [...] - - run: - name: Run dtests (j8_with_vnodes) + time mv ~/cassandra /tmp + cd /tmp/cassandra + if [ -d ~/dtest_jars ]; then + cp ~/dtest_jars/dtest* /tmp/cassandra/build/ + fi - ant clean long-test ++ ant long-test -Dtest.classlistfile=/tmp/java_tests_${CIRCLE_NODE_INDEX}_final.txt -Dtest.classlistprefix=unit no_output_timeout: 15m - command: "echo \"cat /tmp/split_dtest_tests_j8_with_vnodes_final.txt\"\ncat /tmp/split_dtest_tests_j8_with_vnodes_final.txt\n\nsource ~/env3.6/bin/activate\nexport PATH=$JAVA_HOME/bin:$PATH\nif [ -n '' ]; then\n export \nfi\n\njava -version\ncd ~/cassandra-dtest\nmkdir -p /tmp/dtest\n\necho \"env: $(env)\"\necho \"** done env\"\nmkdir -p /tmp/results/dtests\n# we need the \"set -o pipefail\" here so that the exit code that circleci will actually use is from pytest and not the e [...] - store_test_results: - path: /tmp/results + path: /tmp/cassandra/build/test/output/ - store_artifacts: - path: /tmp/dtest - destination: dtest_j8_with_vnodes + path: /tmp/cassandra/build/test/output + destination: junitxml - store_artifacts: - path: ~/cassandra-dtest/logs - destination: dtest_j8_with_vnodes_logs + path: /tmp/cassandra/build/test/logs + destination: logs environment: - JAVA8_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - ANT_HOME: /usr/share/ant @@@ -1251,14 -1579,7 +1641,14 @@@ workflows - utests_compression: requires: - start_utests_compression + - start_utests_stress: + type: approval + requires: + - build + - utests_stress: + requires: + - start_utests_stress - - start_jvm_upgrade_dtest: + - start_j8_dtest_jars_build: type: approval - j8_dtest_jars_build: requires: diff --cc .circleci/config.yml.HIGHRES index 09c8544,521e6c0..19e9ff8 --- a/.circleci/config.yml.HIGHRES +++ b/.circleci/config.yml.HIGHRES @@@ -382,117 -817,16 +817,78 @@@ jobs - REPEATED_DTEST_VNODES: false - REPEATED_DTEST_COUNT: 100 - REPEATED_DTEST_STOP_ON_FAILURE: false + - REPEATED_UPGRADE_DTEST_NAME: null + - REPEATED_UPGRADE_DTEST_COUNT: 100 + - REPEATED_UPGRADE_DTEST_STOP_ON_FAILURE: false + - REPEATED_JVM_UPGRADE_DTEST_CLASS: null + - REPEATED_JVM_UPGRADE_DTEST_METHODS: null + - REPEATED_JVM_UPGRADE_DTEST_COUNT: 100 + - REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE: false - JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - JDK_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - j8_repeated-dtest: ++ utests_stress: + docker: + - image: apache/cassandra-testing-ubuntu2004-java11-w-dependencies:20210304 + resource_class: xlarge + working_directory: ~/ + shell: /bin/bash -eo pipefail -l - parallelism: 100 ++ parallelism: 1 + steps: + - attach_workspace: + at: /home/cassandra + - run: - name: Clone Cassandra dtest Repository (via git) - command: | - git clone --single-branch --branch $DTEST_BRANCH --depth 1 $DTEST_REPO ~/cassandra-dtest - - run: - name: Configure virtualenv and python Dependencies ++ name: Run Unit Tests (stress-test) + command: | - # note, this should be super quick as all dependencies should be pre-installed in the docker image - # if additional dependencies were added to requirmeents.txt and the docker image hasn't been updated - # we'd have to install it here at runtime -- which will make things slow, so do yourself a favor and - # rebuild the docker image! (it automatically pulls the latest requirements.txt on build) - source ~/env3.6/bin/activate + export PATH=$JAVA_HOME/bin:$PATH - pip3 install --upgrade -r ~/cassandra-dtest/requirements.txt - pip3 freeze - - run: - name: Run repeated dtest - no_output_timeout: 15m - command: | - if [ "$REPEATED_DTEST_NAME" == "<nil>" ]; then - echo "Repeated dtest name hasn't been defined, exiting without running any test" - elif [ "$REPEATED_DTEST_COUNT" == "<nil>" ]; then - echo "Repeated dtest count hasn't been defined, exiting without running any test" - elif [ "$REPEATED_DTEST_COUNT" -le 0 ]; then - echo "Repeated dtest count is lesser or equals than zero, exiting without running any test" - else - - # Calculate the number of test iterations to be run by the current parallel runner. - # Since we are running the same test multiple times there is no need to use `circleci tests split`. - count=$((REPEATED_DTEST_COUNT / CIRCLE_NODE_TOTAL)) - if (($CIRCLE_NODE_INDEX < (REPEATED_DTEST_COUNT % CIRCLE_NODE_TOTAL))); then - count=$((count+1)) - fi - - if (($count <= 0)); then - echo "No tests to run in this runner" - else - echo "Running $REPEATED_DTEST_NAME $count times" - - source ~/env3.6/bin/activate - export PATH=$JAVA_HOME/bin:$PATH - - java -version - cd ~/cassandra-dtest - mkdir -p /tmp/dtest - - echo "env: $(env)" - echo "** done env" - mkdir -p /tmp/results/dtests - - stop_on_failure_arg="" - if $REPEATED_UTEST_STOP_ON_FAILURE; then - stop_on_failure_arg="-x" - fi - - vnodes_args="" - if $REPEATED_DTEST_VNODES; then - vnodes_args="--use-vnodes --num-tokens=16" - fi - - # we need the "set -o pipefail" here so that the exit code that circleci will actually use is from pytest and not the exit code from tee - set -o pipefail && cd ~/cassandra-dtest && pytest $vnodes_args --count=$count $stop_on_failure_arg --log-cli-level=DEBUG --junit-xml=/tmp/results/dtests/pytest_result.xml -s --cassandra-dir=/home/cassandra/cassandra --keep-test-dir $REPEATED_DTEST_NAME | tee /tmp/dtest/stdout.txt - fi ++ time mv ~/cassandra /tmp ++ cd /tmp/cassandra ++ if [ -d ~/dtest_jars ]; then ++ cp ~/dtest_jars/dtest* /tmp/cassandra/build/ + fi ++ ant stress-test -Dtest.classlistfile=/tmp/java_tests_${CIRCLE_NODE_INDEX}_final.txt -Dtest.classlistprefix=unit ++ no_output_timeout: 15m + - store_test_results: - path: /tmp/results ++ path: /tmp/cassandra/build/test/output/ + - store_artifacts: - path: /tmp/dtest - destination: dtest ++ path: /tmp/cassandra/build/test/output ++ destination: junitxml + - store_artifacts: - path: ~/cassandra-dtest/logs - destination: dtest_logs ++ path: /tmp/cassandra/build/test/logs ++ destination: logs + environment: + - JAVA8_HOME: /usr/lib/jvm/java-8-openjdk-amd64 + - ANT_HOME: /usr/share/ant + - LANG: en_US.UTF-8 + - KEEP_TEST_DIR: true + - DEFAULT_DIR: /home/cassandra/cassandra-dtest + - PYTHONIOENCODING: utf-8 + - PYTHONUNBUFFERED: true + - CASS_DRIVER_NO_EXTENSIONS: true + - CASS_DRIVER_NO_CYTHON: true + - CASSANDRA_SKIP_SYNC: true + - DTEST_REPO: git://github.com/apache/cassandra-dtest.git + - DTEST_BRANCH: trunk + - CCM_MAX_HEAP_SIZE: 2048M + - CCM_HEAP_NEWSIZE: 512M + - REPEATED_UTEST_TARGET: testsome + - REPEATED_UTEST_CLASS: null + - REPEATED_UTEST_METHODS: null + - REPEATED_UTEST_COUNT: 100 + - REPEATED_UTEST_STOP_ON_FAILURE: false + - REPEATED_DTEST_NAME: null + - REPEATED_DTEST_VNODES: false + - REPEATED_DTEST_COUNT: 100 + - REPEATED_DTEST_STOP_ON_FAILURE: false ++ - REPEATED_UPGRADE_DTEST_NAME: null ++ - REPEATED_UPGRADE_DTEST_COUNT: 100 ++ - REPEATED_UPGRADE_DTEST_STOP_ON_FAILURE: false ++ - REPEATED_JVM_UPGRADE_DTEST_CLASS: null ++ - REPEATED_JVM_UPGRADE_DTEST_METHODS: null ++ - REPEATED_JVM_UPGRADE_DTEST_COUNT: 100 ++ - REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE: false + - JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64 + - JDK_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - utests_stress: + j8_unit_tests: docker: - image: apache/cassandra-testing-ubuntu2004-java11-w-dependencies:20210304 resource_class: xlarge @@@ -553,7 -1014,7 +1076,7 @@@ resource_class: xlarge working_directory: ~/ shell: /bin/bash -eo pipefail -l - parallelism: 100 - parallelism: 1 ++ parallelism: 2 steps: - attach_workspace: at: /home/cassandra @@@ -659,36 -1127,24 +1189,24 @@@ - attach_workspace: at: /home/cassandra - run: - name: Clone Cassandra dtest Repository (via git) - command: | - git clone --single-branch --branch $DTEST_BRANCH --depth 1 $DTEST_REPO ~/cassandra-dtest - - run: - name: Configure virtualenv and python Dependencies + name: Run Unit Tests (long-test) command: | - # note, this should be super quick as all dependencies should be pre-installed in the docker image - # if additional dependencies were added to requirmeents.txt and the docker image hasn't been updated - # we'd have to install it here at runtime -- which will make things slow, so do yourself a favor and - # rebuild the docker image! (it automatically pulls the latest requirements.txt on build) - source ~/env3.6/bin/activate export PATH=$JAVA_HOME/bin:$PATH - pip3 install --upgrade -r ~/cassandra-dtest/requirements.txt - pip3 freeze - - run: - name: Determine Tests to Run (j8_with_vnodes) - no_output_timeout: 5m - command: "# reminder: this code (along with all the steps) is independently executed on every circle container\n# so the goal here is to get the circleci script to return the tests *this* container will run\n# which we do via the `circleci` cli tool.\n\ncd cassandra-dtest\nsource ~/env3.6/bin/activate\nexport PATH=$JAVA_HOME/bin:$PATH\n\nif [ -n '' ]; then\n export \nfi\n\necho \"***Collected DTests (j8_with_vnodes)***\"\nset -eo pipefail && ./run_dtests.py --use-vnodes --skip- [...] - - run: - name: Run dtests (j8_with_vnodes) + time mv ~/cassandra /tmp + cd /tmp/cassandra + if [ -d ~/dtest_jars ]; then + cp ~/dtest_jars/dtest* /tmp/cassandra/build/ + fi - ant clean long-test ++ ant long-test -Dtest.classlistfile=/tmp/java_tests_${CIRCLE_NODE_INDEX}_final.txt -Dtest.classlistprefix=unit no_output_timeout: 15m - command: "echo \"cat /tmp/split_dtest_tests_j8_with_vnodes_final.txt\"\ncat /tmp/split_dtest_tests_j8_with_vnodes_final.txt\n\nsource ~/env3.6/bin/activate\nexport PATH=$JAVA_HOME/bin:$PATH\nif [ -n '' ]; then\n export \nfi\n\njava -version\ncd ~/cassandra-dtest\nmkdir -p /tmp/dtest\n\necho \"env: $(env)\"\necho \"** done env\"\nmkdir -p /tmp/results/dtests\n# we need the \"set -o pipefail\" here so that the exit code that circleci will actually use is from pytest and not the e [...] - store_test_results: - path: /tmp/results + path: /tmp/cassandra/build/test/output/ - store_artifacts: - path: /tmp/dtest - destination: dtest_j8_with_vnodes + path: /tmp/cassandra/build/test/output + destination: junitxml - store_artifacts: - path: ~/cassandra-dtest/logs - destination: dtest_j8_with_vnodes_logs + path: /tmp/cassandra/build/test/logs + destination: logs environment: - JAVA8_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - ANT_HOME: /usr/share/ant @@@ -1251,14 -1579,7 +1641,14 @@@ workflows - utests_compression: requires: - start_utests_compression + - start_utests_stress: + type: approval + requires: + - build + - utests_stress: + requires: + - start_utests_stress - - start_jvm_upgrade_dtest: + - start_j8_dtest_jars_build: type: approval - j8_dtest_jars_build: requires: diff --cc .circleci/config.yml.LOWRES index ff7e3bf,c87c848..1451eea --- a/.circleci/config.yml.LOWRES +++ b/.circleci/config.yml.LOWRES @@@ -382,117 -817,16 +817,78 @@@ jobs - REPEATED_DTEST_VNODES: false - REPEATED_DTEST_COUNT: 100 - REPEATED_DTEST_STOP_ON_FAILURE: false + - REPEATED_UPGRADE_DTEST_NAME: null + - REPEATED_UPGRADE_DTEST_COUNT: 100 + - REPEATED_UPGRADE_DTEST_STOP_ON_FAILURE: false + - REPEATED_JVM_UPGRADE_DTEST_CLASS: null + - REPEATED_JVM_UPGRADE_DTEST_METHODS: null + - REPEATED_JVM_UPGRADE_DTEST_COUNT: 100 + - REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE: false - JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - JDK_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - j8_repeated-dtest: ++ utests_stress: + docker: + - image: apache/cassandra-testing-ubuntu2004-java11-w-dependencies:20210304 + resource_class: medium + working_directory: ~/ + shell: /bin/bash -eo pipefail -l - parallelism: 4 ++ parallelism: 1 + steps: + - attach_workspace: + at: /home/cassandra + - run: - name: Clone Cassandra dtest Repository (via git) - command: | - git clone --single-branch --branch $DTEST_BRANCH --depth 1 $DTEST_REPO ~/cassandra-dtest - - run: - name: Configure virtualenv and python Dependencies ++ name: Run Unit Tests (stress-test) + command: | - # note, this should be super quick as all dependencies should be pre-installed in the docker image - # if additional dependencies were added to requirmeents.txt and the docker image hasn't been updated - # we'd have to install it here at runtime -- which will make things slow, so do yourself a favor and - # rebuild the docker image! (it automatically pulls the latest requirements.txt on build) - source ~/env3.6/bin/activate + export PATH=$JAVA_HOME/bin:$PATH - pip3 install --upgrade -r ~/cassandra-dtest/requirements.txt - pip3 freeze - - run: - name: Run repeated dtest - no_output_timeout: 15m - command: | - if [ "$REPEATED_DTEST_NAME" == "<nil>" ]; then - echo "Repeated dtest name hasn't been defined, exiting without running any test" - elif [ "$REPEATED_DTEST_COUNT" == "<nil>" ]; then - echo "Repeated dtest count hasn't been defined, exiting without running any test" - elif [ "$REPEATED_DTEST_COUNT" -le 0 ]; then - echo "Repeated dtest count is lesser or equals than zero, exiting without running any test" - else - - # Calculate the number of test iterations to be run by the current parallel runner. - # Since we are running the same test multiple times there is no need to use `circleci tests split`. - count=$((REPEATED_DTEST_COUNT / CIRCLE_NODE_TOTAL)) - if (($CIRCLE_NODE_INDEX < (REPEATED_DTEST_COUNT % CIRCLE_NODE_TOTAL))); then - count=$((count+1)) - fi - - if (($count <= 0)); then - echo "No tests to run in this runner" - else - echo "Running $REPEATED_DTEST_NAME $count times" - - source ~/env3.6/bin/activate - export PATH=$JAVA_HOME/bin:$PATH - - java -version - cd ~/cassandra-dtest - mkdir -p /tmp/dtest - - echo "env: $(env)" - echo "** done env" - mkdir -p /tmp/results/dtests - - stop_on_failure_arg="" - if $REPEATED_UTEST_STOP_ON_FAILURE; then - stop_on_failure_arg="-x" - fi - - vnodes_args="" - if $REPEATED_DTEST_VNODES; then - vnodes_args="--use-vnodes --num-tokens=16" - fi - - # we need the "set -o pipefail" here so that the exit code that circleci will actually use is from pytest and not the exit code from tee - set -o pipefail && cd ~/cassandra-dtest && pytest $vnodes_args --count=$count $stop_on_failure_arg --log-cli-level=DEBUG --junit-xml=/tmp/results/dtests/pytest_result.xml -s --cassandra-dir=/home/cassandra/cassandra --keep-test-dir $REPEATED_DTEST_NAME | tee /tmp/dtest/stdout.txt - fi ++ time mv ~/cassandra /tmp ++ cd /tmp/cassandra ++ if [ -d ~/dtest_jars ]; then ++ cp ~/dtest_jars/dtest* /tmp/cassandra/build/ + fi ++ ant stress-test -Dtest.classlistfile=/tmp/java_tests_${CIRCLE_NODE_INDEX}_final.txt -Dtest.classlistprefix=unit ++ no_output_timeout: 15m + - store_test_results: - path: /tmp/results ++ path: /tmp/cassandra/build/test/output/ + - store_artifacts: - path: /tmp/dtest - destination: dtest ++ path: /tmp/cassandra/build/test/output ++ destination: junitxml + - store_artifacts: - path: ~/cassandra-dtest/logs - destination: dtest_logs ++ path: /tmp/cassandra/build/test/logs ++ destination: logs + environment: + - JAVA8_HOME: /usr/lib/jvm/java-8-openjdk-amd64 + - ANT_HOME: /usr/share/ant + - LANG: en_US.UTF-8 + - KEEP_TEST_DIR: true + - DEFAULT_DIR: /home/cassandra/cassandra-dtest + - PYTHONIOENCODING: utf-8 + - PYTHONUNBUFFERED: true + - CASS_DRIVER_NO_EXTENSIONS: true + - CASS_DRIVER_NO_CYTHON: true + - CASSANDRA_SKIP_SYNC: true + - DTEST_REPO: git://github.com/apache/cassandra-dtest.git + - DTEST_BRANCH: trunk + - CCM_MAX_HEAP_SIZE: 1024M + - CCM_HEAP_NEWSIZE: 256M + - REPEATED_UTEST_TARGET: testsome + - REPEATED_UTEST_CLASS: null + - REPEATED_UTEST_METHODS: null + - REPEATED_UTEST_COUNT: 100 + - REPEATED_UTEST_STOP_ON_FAILURE: false + - REPEATED_DTEST_NAME: null + - REPEATED_DTEST_VNODES: false + - REPEATED_DTEST_COUNT: 100 + - REPEATED_DTEST_STOP_ON_FAILURE: false ++ - REPEATED_UPGRADE_DTEST_NAME: null ++ - REPEATED_UPGRADE_DTEST_COUNT: 100 ++ - REPEATED_UPGRADE_DTEST_STOP_ON_FAILURE: false ++ - REPEATED_JVM_UPGRADE_DTEST_CLASS: null ++ - REPEATED_JVM_UPGRADE_DTEST_METHODS: null ++ - REPEATED_JVM_UPGRADE_DTEST_COUNT: 100 ++ - REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE: false + - JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64 + - JDK_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - utests_stress: + j8_unit_tests: docker: - image: apache/cassandra-testing-ubuntu2004-java11-w-dependencies:20210304 resource_class: medium @@@ -659,36 -1127,24 +1189,24 @@@ - attach_workspace: at: /home/cassandra - run: - name: Clone Cassandra dtest Repository (via git) - command: | - git clone --single-branch --branch $DTEST_BRANCH --depth 1 $DTEST_REPO ~/cassandra-dtest - - run: - name: Configure virtualenv and python Dependencies + name: Run Unit Tests (long-test) command: | - # note, this should be super quick as all dependencies should be pre-installed in the docker image - # if additional dependencies were added to requirmeents.txt and the docker image hasn't been updated - # we'd have to install it here at runtime -- which will make things slow, so do yourself a favor and - # rebuild the docker image! (it automatically pulls the latest requirements.txt on build) - source ~/env3.6/bin/activate export PATH=$JAVA_HOME/bin:$PATH - pip3 install --upgrade -r ~/cassandra-dtest/requirements.txt - pip3 freeze - - run: - name: Determine Tests to Run (j8_with_vnodes) - no_output_timeout: 5m - command: "# reminder: this code (along with all the steps) is independently executed on every circle container\n# so the goal here is to get the circleci script to return the tests *this* container will run\n# which we do via the `circleci` cli tool.\n\ncd cassandra-dtest\nsource ~/env3.6/bin/activate\nexport PATH=$JAVA_HOME/bin:$PATH\n\nif [ -n '' ]; then\n export \nfi\n\necho \"***Collected DTests (j8_with_vnodes)***\"\nset -eo pipefail && ./run_dtests.py --use-vnodes --skip- [...] - - run: - name: Run dtests (j8_with_vnodes) + time mv ~/cassandra /tmp + cd /tmp/cassandra + if [ -d ~/dtest_jars ]; then + cp ~/dtest_jars/dtest* /tmp/cassandra/build/ + fi - ant clean long-test ++ ant long-test -Dtest.classlistfile=/tmp/java_tests_${CIRCLE_NODE_INDEX}_final.txt -Dtest.classlistprefix=unit no_output_timeout: 15m - command: "echo \"cat /tmp/split_dtest_tests_j8_with_vnodes_final.txt\"\ncat /tmp/split_dtest_tests_j8_with_vnodes_final.txt\n\nsource ~/env3.6/bin/activate\nexport PATH=$JAVA_HOME/bin:$PATH\nif [ -n '' ]; then\n export \nfi\n\njava -version\ncd ~/cassandra-dtest\nmkdir -p /tmp/dtest\n\necho \"env: $(env)\"\necho \"** done env\"\nmkdir -p /tmp/results/dtests\n# we need the \"set -o pipefail\" here so that the exit code that circleci will actually use is from pytest and not the e [...] - store_test_results: - path: /tmp/results + path: /tmp/cassandra/build/test/output/ - store_artifacts: - path: /tmp/dtest - destination: dtest_j8_with_vnodes + path: /tmp/cassandra/build/test/output + destination: junitxml - store_artifacts: - path: ~/cassandra-dtest/logs - destination: dtest_j8_with_vnodes_logs + path: /tmp/cassandra/build/test/logs + destination: logs environment: - JAVA8_HOME: /usr/lib/jvm/java-8-openjdk-amd64 - ANT_HOME: /usr/share/ant @@@ -1251,14 -1579,7 +1641,14 @@@ workflows - utests_compression: requires: - start_utests_compression + - start_utests_stress: + type: approval + requires: + - build + - utests_stress: + requires: + - start_utests_stress - - start_jvm_upgrade_dtest: + - start_j8_dtest_jars_build: type: approval - j8_dtest_jars_build: requires: diff --cc doc/source/development/testing.rst index 2ec1631,0000000..a0d2ae4 mode 100644,000000..100644 --- a/doc/source/development/testing.rst +++ b/doc/source/development/testing.rst @@@ -1,139 -1,0 +1,170 @@@ +.. Licensed to the Apache Software Foundation (ASF) under one +.. or more contributor license agreements. See the NOTICE file +.. distributed with this work for additional information +.. regarding copyright ownership. The ASF licenses this file +.. to you under the Apache License, Version 2.0 (the +.. "License"); you may not use this file except in compliance +.. with the License. You may obtain a copy of the License at +.. +.. http://www.apache.org/licenses/LICENSE-2.0 +.. +.. Unless required by applicable law or agreed to in writing, software +.. distributed under the License is distributed on an "AS IS" BASIS, +.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +.. See the License for the specific language governing permissions and +.. limitations under the License. + +.. highlight:: none + +Testing +******* + +Creating tests is one of the most important and also most difficult parts of developing Cassandra. There are different ways to test your code depending on what you're working on. + + +Unit Testing +============ + +The most simple way to test code in Cassandra is probably by writing a unit test. Cassandra uses JUnit as a testing framework and test cases can be found in the ``test/unit`` directory. Ideally you’d be able to create a unit test for your implementation that would exclusively cover the class you created (the unit under test). Unfortunately this is not always possible and Cassandra doesn’t have a very mock friendly code base. Often you’ll find yourself in a situation where you have to ma [...] + +.. code-block:: java + + @Test + public void testBatchAndList() throws Throwable + { + createTable("CREATE TABLE %s (k int PRIMARY KEY, l list<int>)"); + execute("BEGIN BATCH " + + "UPDATE %1$s SET l = l +[ 1 ] WHERE k = 0; " + + "UPDATE %1$s SET l = l + [ 2 ] WHERE k = 0; " + + "UPDATE %1$s SET l = l + [ 3 ] WHERE k = 0; " + + "APPLY BATCH"); + + assertRows(execute("SELECT l FROM %s WHERE k = 0"), + row(list(1, 2, 3))); + } + +Unit tests can be run from the command line using the ``ant test`` command, ``ant test -Dtest.name=<simple_classname>`` to execute a test suite or ``ant testsome -Dtest.name=<FQCN> -Dtest.methods=<testmethod1>[,testmethod2]`` for individual tests. For example, to run all test methods in the ``org.apache.cassandra.cql3.SimpleQueryTest`` class, you would run:: + + ant test -Dtest.name=SimpleQueryTest + +To run only the ``testStaticCompactTables()`` test method from that class, you would run:: + + ant testsome -Dtest.name=org.apache.cassandra.cql3.SimpleQueryTest -Dtest.methods=testStaticCompactTables + +Long running tests +------------------ + +Test that consume a significant amount of time during execution can be found in the ``test/long`` directory and executed as a regular JUnit test or standalone program. Except for the execution time, there’s nothing really special about them. However, ant will execute tests under ``test/long`` only when using the ``ant long-test`` target. + +Flaky tests +----------- + +If a test failure is difficult to reproduce you can always use a shell loop, circle repeat strategy and similar solutions. At the JUnit level ``RepeatableRunner`` will let you run a JUnit class N times for convenience. On tests that are fast this is a much faster way to iterate than doing it at the shell level. Beware of tests that modify singleton state or similar as they won't work. + +DTests +====== + +One way of doing integration or system testing at larger scale is by using `dtest <https://github.com/riptano/cassandra-dtest>`_, which stands for “Cassandra Distributed Tests”. The idea is to automatically setup Cassandra clusters using various configurations and simulate certain use cases you want to test. This is done using Python scripts and ``ccmlib`` from the `ccm <https://github.com/pcmanus/ccm>`_ project. Dtests will setup clusters using this library just as you do running ad-ho [...] + +Using dtests helps us to prevent regression bugs by continually executing tests on the `CI server <http://cassci.datastax.com/>`_ against new patches. For frequent contributors, this Jenkins is set up to build branches from their GitHub repositories. It is likely that your reviewer will use this Jenkins instance to run tests for your patch. Read more on the motivation behind the CI server `here <http://www.datastax.com/dev/blog/cassandra-testing-improvements-for-developer-convenience-an [...] + +The best way to learn how to write dtests is probably by reading the introduction "`How to Write a Dtest <http://www.datastax.com/dev/blog/how-to-write-a-dtest>`_" and by looking at existing, recently updated tests in the project. New tests must follow certain `style conventions <https://github.com/apache/cassandra-dtest/blob/trunk/CONTRIBUTING.md>`_ that are being checked before accepting contributions. In contrast to Cassandra, dtest issues and pull-requests are managed on github, the [...] + +Creating a good dtest can be tough, but it should not prevent you from submitting patches! Please ask in the corresponding JIRA ticket how to write a good dtest for the patch. In most cases a reviewer or committer will able to support you, and in some cases they may offer to write a dtest for you. + +Performance Testing +=================== + +Performance tests for Cassandra are a special breed of tests that are not part of the usual patch contribution process. In fact you can contribute tons of patches to Cassandra without ever running performance tests. They are important however when working on performance improvements, as such improvements must be measurable. + +Cassandra Stress Tool +--------------------- + +TODO: `CASSANDRA-12365 <https://issues.apache.org/jira/browse/CASSANDRA-12365>`_ + +cstar_perf +---------- + +Another tool available on github is `cstar_perf <https://github.com/datastax/cstar_perf>`_ that can be used for intensive performance testing in large clusters or locally. Please refer to the project page on how to set it up and how to use it. + +CircleCI +======== + +Cassandra ships with a default `CircleCI <https://circleci.com>`_ configuration, to enable running tests on your branches, you need to go the CircleCI website, click "Login" and log in with your github account. Then you need to give CircleCI permission to watch your repositories. Once you have done that, you can optionally configure CircleCI to run tests in parallel - click "Projects", then your github account and then click the settings for the project. If you leave the parallelism at [...] + +The configuration for CircleCI is in the ``.circleci/config.yml`` file. This configuration file is meant to use low resources, you can find equivalent configuration files using more resources in the same ``.circleci`` directory. Please read the ``readme.md`` file in that directory for further information. Note that the higher resources are not available in the free tier of CircleCI. + - The optional ``repeated_utest``/``repeated_dtest`` CircleCI jobs run a specific JUnit/Python test repeatedly. This is useful to verify that a certain test is stable. It's usually a good idea to run these jobs when adding or modifying a test. To specify what test should be run and the number of repetitions you should edit the related evironment variables in the CircleCI configuration file: - - +------------------------------------+------------------------------------------------------------------+ - | Variable | Description | - +====================================+==================================================================+ - | ``REPEATED_UTEST_TARGET`` | The Ant test target to run, for example: | - | | | - | | * ``testsome`` | - | | * ``test-jvm-dtest-some`` | - | | * ``test-cdc`` | - | | * ``test-compression`` | - | | * ``test-system-keyspace-directory`` | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_UTEST_CLASS`` | The name of the Java test class to be run multiple times, for | - | | example: | - | | | - | | * ``Rorg.apache.cassandra.cql3.ViewTest`` | - | | * ``Rorg.apache.cassandra.distributed.test.PagingTest`` | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_UTEST_METHODS`` | The optional specific methods within ``REPEATED_UTEST_CLASS`` to | - | | be run, for example: | - | | | - | | * ``testCompoundPartitionKey`` | - | | * ``testCompoundPartitionKey,testStaticTable`` | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_UTEST_COUNT`` | The number of times that the repeated Java test should be run | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_UTEST_STOP_ON_FAILURE`` | Whether the utest iteration should stop on the first failure | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_DTEST_NAME`` | The Python dtest to be run multiple times, for example: | - | | | - | | * ``cqlsh_tests/test_cqlsh.py`` | - | | * ``cqlsh_tests/test_cqlsh.py::TestCqlshSmoke`` | - | | * ``cqlsh_tests/test_cqlsh.py::TestCqlshSmoke::test_insert`` | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_DTEST_VNODES`` | Whether the repeated Python dtest should use vnodes | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_DTEST_COUNT`` | The number of times that the repeated Python dtest should be run | - +------------------------------------+------------------------------------------------------------------+ - | ``REPEATED_DTEST_STOP_ON_FAILURE`` | Whether the dtest iteration should stop on the first failure | - +------------------------------------+------------------------------------------------------------------+ ++The optional ``repeated_utest``/``repeated_dtest`` CircleCI jobs run a specific JUnit/Python test repeatedly. In an analogous way, upgrade tests can be run repeatedly with the jobs ``repeated_upgrade_dtest``/``repeated_jvm_upgrade_dtest``. This is useful to verify that a certain test is stable. It's usually a good idea to run these jobs when adding or modifying a test. To specify what test should be run and the number of repetitions you should edit the related evironment variables in th [...] ++ +++----------------------------------------------+---------------------------------------------------------------+ ++| Variable | Description | +++==============================================+===============================================================+ ++|``REPEATED_UTEST_TARGET`` | The Ant test target to run, for example: | ++| | | ++| | * ``testsome`` | ++| | * ``test-jvm-dtest-some`` | ++| | * ``test-cdc`` | ++| | * ``test-compression`` | ++| | * ``test-system-keyspace-directory`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UTEST_CLASS`` | The name of the Java test class to be run multiple times, for | ++| | example: | ++| | | ++| | * ``org.apache.cassandra.cql3.ViewTest`` | ++| | * ``org.apache.cassandra.distributed.test.PagingTest`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UTEST_METHODS`` | The optional specific methods within ``REPEATED_UTEST_CLASS`` | ++| | to be run, for example: | ++| | | ++| | * ``testCompoundPartitionKey`` | ++| | * ``testCompoundPartitionKey,testStaticTable`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UTEST_COUNT`` | The number of times that the repeated Java test should be run | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UTEST_STOP_ON_FAILURE`` | Whether the utest iteration should stop on the first failure | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_DTEST_NAME`` | The Python dtest to be run multiple times, for example: | ++| | | ++| | * ``cqlsh_tests/test_cqlsh.py`` | ++| | * ``cqlsh_tests/test_cqlsh.py::TestCqlshSmoke`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_DTEST_VNODES`` | Whether the repeated Python dtest should use vnodes | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_DTEST_COUNT`` | The number of times that the repeated Python dtest should be | ++| | run | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_DTEST_STOP_ON_FAILURE`` | Whether the dtest iteration should stop on the first failure | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UPGRADE_DTEST_NAME`` | A Python upgrade dtest to be run multiple times, for example: | ++| | | ++| | * ``upgrade_tests/cql_tests.py`` | ++| | * ``upgrade_tests/repair_test.py`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UPGRADE_DTEST_COUNT`` | The number of times that the repeated Python upgrade dtest | ++| | should be run | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_UPGRADE_DTEST_STOP_ON_ | Whether the Python upgrade dtest iteration should stop on the | ++|FAILURE`` | first failure | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_JVM_UPGRADE_DTEST_CLASS`` | The name of JVM upgrade dtest class to be run multiple times, | ++| | for example: | ++| | | ++| | * | ``org.apache.cassandra.distributed.upgrade.`` | ++| | | ``MixedModeAvailabilityV30Test`` | ++| | * | ``org.apache.cassandra.distributed.upgrade.`` | ++| | | ``MixedModeConsistencyV3XTest`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_JVM_UPGRADE_DTEST_METHODS`` | The optional specific methods within | ++| | ``REPEATED_JVM_UPGRADE_DTEST_CLASS`` to be run, for example: | ++| | | ++| | * ``testAvailabilityV30ToV4`` | ++| | * ``testAvailabilityV30ToV3X,testAvailabilityV30ToV4`` | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_JVM_UPGRADE_DTEST_COUNT`` | The number of times that the repeated JVM upgrade dtest | ++| | should be run | +++----------------------------------------------+---------------------------------------------------------------+ ++|``REPEATED_JVM_UPGRADE_DTEST_STOP_ON_FAILURE``| Whether the JVM upgrade dtest iteration should stop on the | ++| | first failure | +++----------------------------------------------+---------------------------------------------------------------+ + + --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
